From f4d26fa758ed767722934cb2738c35be4a478bc9 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 26 Jan 2016 21:00:19 +0300 Subject: [PATCH] Menu/Win (Command) key support; OSX native shortcuts - close #121 --- src/dlangui/core/events.d | 6 +++++- src/dlangui/widgets/editors.d | 3 ++- src/dlangui/widgets/widget.d | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dlangui/core/events.d b/src/dlangui/core/events.d index fcbb0325..e96a6cdc 100644 --- a/src/dlangui/core/events.d +++ b/src/dlangui/core/events.d @@ -769,7 +769,11 @@ enum KeyFlag : uint { /// Left Shift key is down LShift = 0x0204, /// Left Alt key is down - LAlt = 0x0280 + LAlt = 0x0280, + /// Left Menu/Win key is down + LMenu = 0x0240, + /// Right Menu/Win key is down + RMenu = 0x0140 } /// Key code constants for KeyEvent diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 9704e2e8..5feedda1 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -1555,6 +1555,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction /// handle keys override bool onKeyEvent(KeyEvent event) { + //Log.d("onKeyEvent ", event.action, " ", event.keyCode, " flags ", event.flags); if (focused) startCaretBlinking(); cancelHoverTimer(); bool ctrlOrAltPressed = false; //(event.flags & (KeyFlag.Control /* | KeyFlag.Alt */)); @@ -1595,7 +1596,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction protected void onHover(Point pos) { if (_hoverMousePosition == pos) return; - Log.d("onHover ", pos); + //Log.d("onHover ", pos); int x = pos.x - left - _leftPaneWidth; int y = pos.y - top; _hoverMousePosition = pos; diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index ebc906da..a259d8fa 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -1100,7 +1100,7 @@ public: if (keyEvent.assigned && keyEvent(this, event)) return true; // processed by external handler if (event.action == KeyAction.KeyDown) { - Action action = findKeyAction(event.keyCode, event.flags & (KeyFlag.Shift | KeyFlag.Alt | KeyFlag.Control)); + Action action = findKeyAction(event.keyCode, event.flags & (KeyFlag.Shift | KeyFlag.Alt | KeyFlag.Control | KeyFlag.Menu)); if (action !is null) { return dispatchAction(action); }