mirror of https://github.com/buggins/dlangui.git
close dialog on ESC key - fix #313
This commit is contained in:
parent
f1c2f4d530
commit
a112994a4f
|
@ -364,9 +364,7 @@ class Action {
|
|||
_iconId = a._iconId;
|
||||
_state = a._state;
|
||||
_defaultState = a._defaultState;
|
||||
_accelerators.length = a._accelerators.length;
|
||||
foreach(i; 0 .. _accelerators.length)
|
||||
_accelerators[i] = a._accelerators[i];
|
||||
_accelerators = a._accelerators.dup;
|
||||
_stringParam = a._stringParam;
|
||||
_longParam = a._longParam;
|
||||
if (a._objectParam)
|
||||
|
@ -484,7 +482,7 @@ class Action {
|
|||
return this;
|
||||
}
|
||||
/// returns true if accelerator matches provided key code and flags
|
||||
bool checkAccelerator(uint keyCode, uint keyFlags) {
|
||||
bool checkAccelerator(uint keyCode, uint keyFlags) const {
|
||||
foreach(a; _accelerators) {
|
||||
if (a.keyCode == keyCode && matchKeyFlags(keyFlags, a.keyFlags))
|
||||
return true;
|
||||
|
|
|
@ -40,7 +40,7 @@ enum StandardAction : int {
|
|||
}
|
||||
|
||||
const Action ACTION_OK = new Action(StandardAction.Ok, "ACTION_OK"c, "dialog-ok");
|
||||
const Action ACTION_CANCEL = new Action(StandardAction.Cancel, "ACTION_CANCEL"c, "dialog-cancel");
|
||||
const Action ACTION_CANCEL = new Action(StandardAction.Cancel, "ACTION_CANCEL"c, "dialog-cancel").addAccelerator(KeyCode.ESCAPE);
|
||||
const Action ACTION_APPLY = new Action(StandardAction.Apply, "ACTION_APPLY"c, null);
|
||||
const Action ACTION_YES = new Action(StandardAction.Yes, "ACTION_YES"c, "dialog-ok");
|
||||
const Action ACTION_NO = new Action(StandardAction.No, "ACTION_NO"c, "dialog-cancel");
|
||||
|
|
|
@ -142,6 +142,15 @@ class Dialog : VerticalLayout {
|
|||
return res;
|
||||
}
|
||||
|
||||
/// map key to action
|
||||
override Action findKeyAction(uint keyCode, uint flags) {
|
||||
foreach(a; _buttonActions) {
|
||||
if (a.checkAccelerator(keyCode, flags))
|
||||
return a.clone;
|
||||
}
|
||||
return super.findKeyAction(keyCode, flags);
|
||||
}
|
||||
|
||||
/// Custom handling of actions
|
||||
override bool handleAction(const Action action) {
|
||||
foreach(const Action a; _buttonActions)
|
||||
|
|
|
@ -273,7 +273,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return super.onKeyEvent(event);
|
||||
}
|
||||
|
||||
/// return true for custom drawn cell
|
||||
|
|
Loading…
Reference in New Issue