summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrustable-code <krauter.simon@arcor.de>2018-05-20 14:05:07 +0200
committertrustable-code <krauter.simon@arcor.de>2018-05-20 14:05:07 +0200
commitcab28ddcaef2b1d2866c98f8f72109cbbb20348d (patch)
treeed8619330f8a69a73a3b7508b13712d4389252ae /src
parentca4d9584c75ce0db8f338d3ec5351729335037b0 (diff)
downloadNiGui-cab28ddcaef2b1d2866c98f8f72109cbbb20348d.tar.gz
NiGui-cab28ddcaef2b1d2866c98f8f72109cbbb20348d.zip
Fixed #26 and simplified code
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nigui.nim9
-rwxr-xr-xsrc/nigui/private/gtk3/platform_impl.nim31
-rwxr-xr-xsrc/nigui/private/windows/platform_impl.nim25
3 files changed, 31 insertions, 34 deletions
diff --git a/src/nigui.nim b/src/nigui.nim
index 11a318d..41b135a 100755
--- a/src/nigui.nim
+++ b/src/nigui.nim
@@ -946,15 +946,6 @@ proc rgb(red, green, blue: byte, alpha: byte = 255): Color =
result.blue = blue
result.alpha = alpha
-proc unicodeToUpper(unicode: int): int =
- if unicode < 128:
- return cast[int](cast[char](unicode).toUpper)
- result = case unicode:
- of 228: 196 # Ä
- of 246: 214 # Ö
- of 252: 220 # Ü
- else: unicode
-
proc sleep(app: App, milliSeconds: float) =
let t = epochTime() + milliSeconds / 1000
while epochTime() < t:
diff --git a/src/nigui/private/gtk3/platform_impl.nim b/src/nigui/private/gtk3/platform_impl.nim
index 6fb5bb5..57766e2 100755
--- a/src/nigui/private/gtk3/platform_impl.nim
+++ b/src/nigui/private/gtk3/platform_impl.nim
@@ -62,6 +62,35 @@ proc pWindowConfigureSignal(windowHandle, event, data: pointer): bool {.cdecl.}
proc pKeyvalToKey(keyval: cint): Key =
result = case keyval
+ of 97: Key_A
+ of 98: Key_B
+ of 99: Key_C
+ of 100: Key_D
+ of 101: Key_E
+ of 102: Key_F
+ of 103: Key_G
+ of 104: Key_H
+ of 105: Key_I
+ of 106: Key_J
+ of 107: Key_K
+ of 108: Key_L
+ of 109: Key_M
+ of 110: Key_N
+ of 111: Key_O
+ of 112: Key_P
+ of 113: Key_Q
+ of 114: Key_R
+ of 115: Key_S
+ of 116: Key_T
+ of 117: Key_U
+ of 118: Key_V
+ of 119: Key_W
+ of 120: Key_X
+ of 121: Key_Y
+ of 122: Key_Z
+ of 228: Key_AE
+ of 246: Key_OE
+ of 252: Key_UE
of 65106: Key_Circumflex
of 65289: Key_Tab
of 65293: Key_Return
@@ -83,7 +112,7 @@ proc pKeyvalToKey(keyval: cint): Key =
of 65508: Key_ControlR
of 65513: Key_AltL
of 65514: Key_AltR
- else: cast[Key](keyval.unicodeToUpper)
+ else: cast[Key](keyval)
proc pWindowKeyPressSignal(widget: pointer, event: var GdkEventKey, data: pointer): bool {.cdecl.} =
let window = cast[WindowImpl](data)
diff --git a/src/nigui/private/windows/platform_impl.nim b/src/nigui/private/windows/platform_impl.nim
index 356cd0d..63c7b7c 100755
--- a/src/nigui/private/windows/platform_impl.nim
+++ b/src/nigui/private/windows/platform_impl.nim
@@ -208,29 +208,6 @@ proc pCommonWndProc(hWnd: pointer, uMsg: int32, wParam, lParam: pointer): pointe
discard
result = DefWindowProcA(hWnd, uMsg, wParam, lParam)
-proc pVirtualKeyToKey(keyval, scancode: int32): Key =
- case keyval
- of VK_CONTROL, VK_SHIFT, VK_MENU:
- case MapVirtualKeyW(scancode, MAPVK_VSC_TO_VK_EX)
- of VK_LCONTROL: result = Key_ControlL
- of VK_RCONTROL: result = Key_ControlR
- of VK_LSHIFT: result = Key_ShiftL
- of VK_RSHIFT: result = Key_ShiftR
- of VK_LMENU: result = Key_AltL
- of VK_RMENU: result = Key_AltR
- else: discard
- of VK_PRIOR: result = Key_PageUp
- of VK_NEXT: result = Key_PageDown
- of VK_END: result = Key_End
- of VK_HOME: result = Key_Home
- of VK_LEFT: result = Key_Left
- of VK_UP: result = Key_Up
- of VK_RIGHT: result = Key_Right
- of VK_DOWN: result = Key_Down
- of VK_INSERT: result = Key_Insert
- of VK_DELETE: result = Key_Delete
- else: result = cast[Key](keyval.unicodeToUpper)
-
proc pWMParamsToKey(wParam, lParam: pointer): Key =
case cast[int32](wParam)
of VK_CONTROL, VK_SHIFT, VK_MENU:
@@ -254,7 +231,7 @@ proc pWMParamsToKey(wParam, lParam: pointer): Key =
of VK_INSERT: result = Key_Insert
of VK_DELETE: result = Key_Delete
of VK_OEM_5: result = Key_Circumflex
- else: result = cast[Key](cast[int32](wParam).unicodeToUpper)
+ else: result = cast[Key](cast[int32](wParam))
proc pHandleWMKEYDOWNOrWMCHAR(window: Window, control: Control, unicode: int): bool =
internalKeyDown(pKeyDownKey)