diff options
| author | trustable-code <krauter.simon@arcor.de> | 2018-05-14 21:02:46 +0200 |
|---|---|---|
| committer | trustable-code <krauter.simon@arcor.de> | 2018-05-14 21:02:46 +0200 |
| commit | ca4d9584c75ce0db8f338d3ec5351729335037b0 (patch) | |
| tree | 7de86d5ed6d0638e08b15d80108f161ad79541b7 /src | |
| parent | b0efefc389e7666b3119f15781c403c0ded7e574 (diff) | |
| download | NiGui-ca4d9584c75ce0db8f338d3ec5351729335037b0.tar.gz NiGui-ca4d9584c75ce0db8f338d3ec5351729335037b0.zip | |
Make copy & paste work again on Windows
Ctrl+C, Ctrl+X and Ctrl+V are now mapped to the corresponding clipboard
action.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/nigui/private/windows/platform_impl.nim | 25 | ||||
| -rwxr-xr-x | src/nigui/private/windows/windows.nim | 3 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/nigui/private/windows/platform_impl.nim b/src/nigui/private/windows/platform_impl.nim index f95d92c..356cd0d 100755 --- a/src/nigui/private/windows/platform_impl.nim +++ b/src/nigui/private/windows/platform_impl.nim @@ -364,10 +364,8 @@ proc pWindowWndProc(hWnd: pointer, uMsg: int32, wParam, lParam: pointer): pointe if window != nil: if cast[int](wParam) == SC_MINIMIZE: window.fMinimized = true - echo "a" elif cast[int](wParam) == SC_RESTORE: window.fMinimized = false - echo "b" else: discard result = pCommonWndProc(hWnd, uMsg, wParam, lParam) @@ -1077,8 +1075,6 @@ proc pCommonControlWndProc(hWnd: pointer, uMsg: int32, wParam, lParam: pointer): of WM_KEYUP: internalKeyUp(pWMParamsToKey(wParam, lParam)) - - # of WM_KEYUP: # return nil # key is still inserted in text area of WM_CHAR: @@ -1146,6 +1142,21 @@ proc pTextControlWndProc(hWnd: pointer, uMsg: int32, wParam, lParam: pointer): P discard SendMessageA(hwnd, EM_SETSEL, nil, cast[pointer](-1)) return PWndProcResult_False + # Handle Ctrl+C: + if uMsg == WM_KEYDOWN and cast[char](wParam) == 'C' and GetKeyState(VK_CONTROL) <= -127: + discard SendMessageA(hwnd, WM_COPY, nil, nil) + return PWndProcResult_False + + # Handle Ctrl+X: + if uMsg == WM_KEYDOWN and cast[char](wParam) == 'X' and GetKeyState(VK_CONTROL) <= -127: + discard SendMessageA(hwnd, WM_CUT, nil, nil) + return PWndProcResult_False + + # Handle Ctrl+V: + if uMsg == WM_KEYDOWN and cast[char](wParam) == 'V' and GetKeyState(VK_CONTROL) <= -127: + discard SendMessageA(hwnd, WM_PASTE, nil, nil) + return PWndProcResult_False + # Prevent 'ding' sound when a character key together with Ctrl or Alt (but not both) is pressed: if uMsg == WM_CHAR and GetKeyState(VK_CONTROL) <= -127 and GetKeyState(VK_MENU) >= 0: return PWndProcResult_False @@ -1421,12 +1432,6 @@ proc init(textArea: NativeTextArea) = pTextAreaOrigWndProc = pSetWindowLongPtr(textArea.fHandle, GWLP_WNDPROC, pTextAreaWndProc) textArea.TextArea.init() -# method text(textArea: NativeTextArea): string = pGetWindowText(textArea.fHandle) -# not needed any more - -# method `text=`(textArea: NativeTextArea, text: string) = pSetWindowText(textArea.fHandle, text) -# not needed any more - method scrollToBottom(textArea: NativeTextArea) = # select all discard SendMessageA(textArea.fHandle, EM_SETSEL, nil, cast[pointer](-1)) diff --git a/src/nigui/private/windows/windows.nim b/src/nigui/private/windows/windows.nim index 902b39b..f88c510 100755 --- a/src/nigui/private/windows/windows.nim +++ b/src/nigui/private/windows/windows.nim @@ -141,6 +141,9 @@ const WM_SYSKEYDOWN* = 260 WM_SYSCOMMAND* = 274 WM_CTLCOLOREDIT* = 307 + WM_CUT* = 0x0300 + WM_COPY* = 0x0301 + WM_PASTE* = 0x0302 WS_CLIPCHILDREN* = 0x02000000 WS_CAPTION* = 0x00C00000 WS_CHILD* = 0x40000000 |
