mirror of https://github.com/buggins/dlangui.git
Alt+Letter should activate main menu if hotkey is set
This commit is contained in:
parent
52a2795af3
commit
3b7ac98ab2
|
|
@ -977,15 +977,23 @@ class MainMenu : MenuWidgetBase {
|
||||||
// handle MainMenu activation / deactivation (Alt, Esc...)
|
// handle MainMenu activation / deactivation (Alt, Esc...)
|
||||||
bool toggleMenu = false;
|
bool toggleMenu = false;
|
||||||
bool isAlt = event.keyCode == KeyCode.ALT || event.keyCode == KeyCode.LALT || event.keyCode == KeyCode.RALT;
|
bool isAlt = event.keyCode == KeyCode.ALT || event.keyCode == KeyCode.LALT || event.keyCode == KeyCode.RALT;
|
||||||
|
bool altPressed = !!(event.flags & KeyFlag.Alt);
|
||||||
bool noOtherModifiers = !(event.flags & (KeyFlag.Shift | KeyFlag.Control));
|
bool noOtherModifiers = !(event.flags & (KeyFlag.Shift | KeyFlag.Control));
|
||||||
|
|
||||||
if (event.action == KeyAction.KeyDown && event.keyCode == KeyCode.ESCAPE && event.flags == 0 && activated) {
|
if (event.action == KeyAction.KeyDown && event.keyCode == KeyCode.ESCAPE && event.flags == 0 && activated) {
|
||||||
deactivate();
|
deactivate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.action == KeyAction.Text && (event.flags & KeyFlag.Alt) && !(event.flags & KeyFlag.Shift) && !(event.flags & KeyFlag.Shift)) {
|
dchar hotkey = 0;
|
||||||
dchar ch = event.text[0];
|
if (event.action == KeyAction.KeyDown && event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z && altPressed && noOtherModifiers) {
|
||||||
int index = _item.findSubitemByHotkey(ch);
|
// Log.d("Alt + a..z");
|
||||||
|
hotkey = cast(dchar)((event.keyCode - KeyCode.KEY_A) + 'a');
|
||||||
|
}
|
||||||
|
if (event.action == KeyAction.Text && altPressed && noOtherModifiers) {
|
||||||
|
hotkey = event.text[0];
|
||||||
|
}
|
||||||
|
if (hotkey) {
|
||||||
|
int index = _item.findSubitemByHotkey(hotkey);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
activate();
|
activate();
|
||||||
itemClicked(index);
|
itemClicked(index);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue