# HG changeset patch # User Jordan Miner # Date 1249973142 18000 # Node ID 8dac206ea523913741f0030279c5e9ea575473f6 # Parent 63ea570c8d7c3b6d3769c7a219a5465c25ac0040 Add shift/control/altDown to KeyEventArgs. diff -r 63ea570c8d7c -r 8dac206ea523 dynamin/gui/events.d --- a/dynamin/gui/events.d Mon Aug 10 17:04:08 2009 -0500 +++ b/dynamin/gui/events.d Tue Aug 11 01:45:42 2009 -0500 @@ -119,10 +119,14 @@ class KeyEventArgs : StopEventArgs { Key _key; bool _repeat; + bool _shiftDown, _controlDown, _altDown; public: - this(Key key, bool repeat) { + this(Key key, bool repeat, bool shift, bool ctrl, bool alt) { _key = key; _repeat = repeat; + _shiftDown = shift; + _controlDown = ctrl; + _altDown = alt; } /** * Returns: the key that was typed. @@ -135,6 +139,12 @@ * if the key was just pressed */ bool repeat() { return _repeat; } + // Returns true if the shift key is currently down and false otherwise. + bool shiftDown() { return _shiftDown; } + // Returns true if the control key is currently down and false otherwise. + bool controlDown() { return _controlDown; } + // Returns true if the alt key is currently down and false otherwise. + bool altDown() { return _altDown; } string toString() { return format("KeyEventArgs [key={}, repeat={}]", _key, _repeat); } diff -r 63ea570c8d7c -r 8dac206ea523 dynamin/gui/windows_window.d --- a/dynamin/gui/windows_window.d Mon Aug 10 17:04:08 2009 -0500 +++ b/dynamin/gui/windows_window.d Tue Aug 11 01:45:42 2009 -0500 @@ -566,6 +566,9 @@ default: return MouseButton.None; } } + bool isKeyDown(int vk) { + return cast(bool)HIWORD(GetKeyState(vk)); + } //}}} switch(uMsg) { case WM_ENTERSIZEMOVE: //when the user starts moving or resizing the window @@ -801,8 +804,9 @@ case WM_KEYDOWN: //Stdout.format("WM_KEYDOWN: {:x}", cast(int)wParam).newline; Control focused = c.focusedControl ? c.focusedControl : c; - scope args = new KeyEventArgs( - VKToKey(wParam), cast(bool)(lParam & (1 << 30)) ); + scope args = new KeyEventArgs(VKToKey(wParam), + cast(bool)(lParam & (1 << 30)), isKeyDown(VK_SHIFT), + isKeyDown(VK_CONTROL), isKeyDown(VK_MENU) ); focused.keyDown(args); return 0; case WM_SYSKEYUP: @@ -812,7 +816,8 @@ case WM_KEYUP: //Stdout.format("WM_KEYUP: {:x}", cast(int)wParam).newline; Control focused = c.focusedControl ? c.focusedControl : c; - scope args = new KeyEventArgs( VKToKey(wParam), false ); + scope args = new KeyEventArgs( VKToKey(wParam), false, + isKeyDown(VK_SHIFT), isKeyDown(VK_CONTROL), isKeyDown(VK_MENU) ); focused.keyUp(args); return 0; case WM_CHAR: