mirror of https://github.com/buggins/dlangui.git
fix crash on menu shortcut search - for buggins/dlangide#318
This commit is contained in:
parent
43cc077dd7
commit
de372e7a4a
|
@ -155,6 +155,8 @@ class MenuItem {
|
||||||
dchar getHotkey() {
|
dchar getHotkey() {
|
||||||
static import std.uni;
|
static import std.uni;
|
||||||
dstring s = label;
|
dstring s = label;
|
||||||
|
if (s.length < 2)
|
||||||
|
return 0;
|
||||||
dchar ch = 0;
|
dchar ch = 0;
|
||||||
for (int i = 0; i < s.length - 1; i++) {
|
for (int i = 0; i < s.length - 1; i++) {
|
||||||
if (s[i] == '&') {
|
if (s[i] == '&') {
|
||||||
|
@ -1069,17 +1071,18 @@ class MainMenu : MenuWidgetBase {
|
||||||
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 altPressed = !!(event.flags & KeyFlag.Alt);
|
||||||
bool noOtherModifiers = !(event.flags & (KeyFlag.Shift | KeyFlag.Control));
|
bool noOtherModifiers = !(event.flags & (KeyFlag.Shift | KeyFlag.Control));
|
||||||
|
bool noAltGrKey = !((event.flags & KeyFlag.RAlt) == KeyFlag.RAlt);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
dchar hotkey = 0;
|
dchar hotkey = 0;
|
||||||
if (event.action == KeyAction.KeyDown && event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z && altPressed && noOtherModifiers) {
|
if (event.action == KeyAction.KeyDown && event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z && altPressed && noOtherModifiers && noAltGrKey) {
|
||||||
// Log.d("Alt + a..z");
|
// Log.d("Alt + a..z");
|
||||||
hotkey = cast(dchar)((event.keyCode - KeyCode.KEY_A) + 'a');
|
hotkey = cast(dchar)((event.keyCode - KeyCode.KEY_A) + 'a');
|
||||||
}
|
}
|
||||||
if (event.action == KeyAction.Text && altPressed && noOtherModifiers) {
|
if (event.action == KeyAction.Text && altPressed && noOtherModifiers && noAltGrKey) {
|
||||||
hotkey = event.text[0];
|
hotkey = event.text[0];
|
||||||
}
|
}
|
||||||
if (hotkey) {
|
if (hotkey) {
|
||||||
|
|
Loading…
Reference in New Issue