action shortcut override - fix #458

This commit is contained in:
Vadim Lopatin 2017-09-26 11:24:52 +03:00
parent b942bdd35f
commit 2ed9a8d394
3 changed files with 9 additions and 7 deletions

View File

@ -47,7 +47,7 @@ struct Accelerator {
/// Key flags bit set, usually one of KeyFlag enum items /// Key flags bit set, usually one of KeyFlag enum items
uint keyFlags; uint keyFlags;
/// Returns accelerator text description /// Returns accelerator text description
@property dstring label() { @property dstring label() const {
dstring buf; dstring buf;
version (OSX) { version (OSX) {
static if (true) { static if (true) {
@ -474,9 +474,10 @@ class Action {
} }
/// returns text description for first accelerator of action; null if no accelerators /// returns text description for first accelerator of action; null if no accelerators
@property dstring acceleratorText() { @property dstring acceleratorText() {
if (_accelerators.length < 1) Accelerator[] acc = accelerators;
if (acc.length < 1)
return null; return null;
return _accelerators[0].label; return acc[0].label;
} }
/// returns tooltip text for action /// returns tooltip text for action
@property dstring tooltipText() { @property dstring tooltipText() {
@ -516,7 +517,7 @@ class Action {
} }
/// returns true if accelerator matches provided key code and flags /// returns true if accelerator matches provided key code and flags
bool checkAccelerator(uint keyCode, uint keyFlags) const { bool checkAccelerator(uint keyCode, uint keyFlags) const {
foreach(a; _accelerators) { foreach(a; accelerators) {
if (a.keyCode == keyCode && matchKeyFlags(keyFlags, a.keyFlags)) if (a.keyCode == keyCode && matchKeyFlags(keyFlags, a.keyFlags))
return true; return true;
} }
@ -1741,8 +1742,9 @@ void setActionAccelerators(int actionId, Accelerator[] accelerators) {
} }
/// lookup accelerators override for action by id /// lookup accelerators override for action by id
Accelerator[] findActionAccelerators(int actionId) { Accelerator[] findActionAccelerators(int actionId) {
if (auto found = actionId in actionAcceleratorsMap) if (auto found = actionId in actionAcceleratorsMap) {
return *found; return *found;
}
return null; return null;
} }
/// lookup accelerators override for action by name (e.g. "EditorActions.ToggleLineComment") /// lookup accelerators override for action by name (e.g. "EditorActions.ToggleLineComment")

View File

@ -230,7 +230,7 @@ const Action[] STD_EDITOR_ACTIONS = [ACTION_EDITOR_INSERT_NEW_LINE, ACTION_EDITO
ACTION_EDITOR_APPEND_NEW_LINE, ACTION_EDITOR_DELETE_LINE, ACTION_EDITOR_TOGGLE_REPLACE_MODE, ACTION_EDITOR_APPEND_NEW_LINE, ACTION_EDITOR_DELETE_LINE, ACTION_EDITOR_TOGGLE_REPLACE_MODE,
ACTION_EDITOR_SELECT_ALL, ACTION_EDITOR_TOGGLE_LINE_COMMENT, ACTION_EDITOR_TOGGLE_BLOCK_COMMENT, ACTION_EDITOR_SELECT_ALL, ACTION_EDITOR_TOGGLE_LINE_COMMENT, ACTION_EDITOR_TOGGLE_BLOCK_COMMENT,
ACTION_EDITOR_TOGGLE_BOOKMARK, ACTION_EDITOR_GOTO_NEXT_BOOKMARK, ACTION_EDITOR_GOTO_PREVIOUS_BOOKMARK, ACTION_EDITOR_TOGGLE_BOOKMARK, ACTION_EDITOR_GOTO_NEXT_BOOKMARK, ACTION_EDITOR_GOTO_PREVIOUS_BOOKMARK,
ACTION_EDITOR_FIND, ACTION_EDITOR_REPLACE, ACTION_EDITOR_FIND_NEXT, ACTION_EDITOR_FIND_PREV, ACTION_EDITOR_FIND, ACTION_EDITOR_REPLACE,
ACTION_EDITOR_FIND_NEXT, ACTION_EDITOR_FIND_PREV ACTION_EDITOR_FIND_NEXT, ACTION_EDITOR_FIND_PREV
]; ];

View File

@ -1 +1 @@
v0.9.146 v0.9.147