Mercurial > projects > dynamin
changeset 72:8dac206ea523
Add shift/control/altDown to KeyEventArgs.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Tue, 11 Aug 2009 01:45:42 -0500 |
parents | 63ea570c8d7c |
children | 68be24186634 |
files | dynamin/gui/events.d dynamin/gui/windows_window.d |
diffstat | 2 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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: