mirror of https://github.com/buggins/dlangui.git
fix Ctrl+Space shortcuts support - for dlangide#146
This commit is contained in:
parent
63cc8d56ff
commit
46acde9ef0
|
@ -1692,16 +1692,24 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
return super.findKeyAction(keyCode, flags);
|
||||
}
|
||||
|
||||
static bool isAZaz(dchar ch) {
|
||||
return (ch >= 'a' && ch <='z') || (ch >= 'A' && ch <='Z');
|
||||
}
|
||||
|
||||
/// 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 */));
|
||||
bool ctrlOrAltPressed = !!(event.flags & KeyFlag.Control); //(event.flags & (KeyFlag.Control /* | KeyFlag.Alt */));
|
||||
//if (event.action == KeyAction.KeyDown && event.keyCode == KeyCode.SPACE && (event.flags & KeyFlag.Control)) {
|
||||
// Log.d("Ctrl+Space pressed");
|
||||
//}
|
||||
if (event.action == KeyAction.Text && event.text.length && !ctrlOrAltPressed) {
|
||||
//Log.d("text entered: ", event.text);
|
||||
if (readOnly)
|
||||
return true;
|
||||
if (!(!!(event.flags & KeyFlag.Alt) && event.text.length == 1 && isAZaz(event.text[0]))) { // filter out Alt+A..Z
|
||||
if (replaceMode && _selectionRange.empty && _content[_caretPos.line].length >= _caretPos.pos + event.text.length) {
|
||||
// replace next char(s)
|
||||
TextRange range = _selectionRange;
|
||||
|
@ -1715,9 +1723,10 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
if (focused) startCaretBlinking();
|
||||
return true;
|
||||
}
|
||||
if (event.keyCode == KeyCode.SPACE && !readOnly) {
|
||||
return true;
|
||||
}
|
||||
//if (event.keyCode == KeyCode.SPACE && !readOnly) {
|
||||
// return true;
|
||||
//}
|
||||
//if (event.keyCode == KeyCode.RETURN && !readOnly && !_content.multiline) {
|
||||
// return true;
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue