mirror of https://github.com/buggins/dlangui.git
add LineEdit enterKey signal
This commit is contained in:
parent
364a02da9d
commit
e78cd9a63b
|
@ -1078,7 +1078,7 @@ class FilePathPanel : FrameLayout {
|
||||||
_segments = new FilePathPanelButtons(ID_SEGMENTS);
|
_segments = new FilePathPanelButtons(ID_SEGMENTS);
|
||||||
_edPath = new EditLine(ID_EDITOR);
|
_edPath = new EditLine(ID_EDITOR);
|
||||||
_edPath.layoutWidth = FILL_PARENT;
|
_edPath.layoutWidth = FILL_PARENT;
|
||||||
_edPath.editorAction = &onEditorAction;
|
_edPath.enterKey = &onEnterKey;
|
||||||
_edPath.focusChange = &onEditorFocusChanged;
|
_edPath.focusChange = &onEditorFocusChanged;
|
||||||
_segments.click = &onSegmentsClickOutside;
|
_segments.click = &onSegmentsClickOutside;
|
||||||
_segments.onPathSelectionListener = &onPathSelected;
|
_segments.onPathSelectionListener = &onPathSelected;
|
||||||
|
@ -1106,13 +1106,11 @@ class FilePathPanel : FrameLayout {
|
||||||
_edPath.setFocus();
|
_edPath.setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
protected bool onEditorAction(const Action action) {
|
protected bool onEnterKey(EditWidgetBase editor) {
|
||||||
if (action.id == EditorActions.InsertNewLine) {
|
|
||||||
string fn = buildNormalizedPath(toUTF8(_edPath.text));
|
string fn = buildNormalizedPath(toUTF8(_edPath.text));
|
||||||
if (exists(fn) && isDir(fn))
|
if (exists(fn) && isDir(fn))
|
||||||
return onPathSelected(fn);
|
onPathSelected(fn);
|
||||||
}
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property void path(string value) {
|
@property void path(string value) {
|
||||||
|
@ -1144,6 +1142,11 @@ class FileNameEditLine : HorizontalLayout {
|
||||||
return _edFileName.editorAction;
|
return _edFileName.editorAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// handle Enter key press inside line editor
|
||||||
|
@property ref Signal!EnterKeyHandler enterKey() {
|
||||||
|
return _edFileName.enterKey;
|
||||||
|
}
|
||||||
|
|
||||||
this(string ID = null) {
|
this(string ID = null) {
|
||||||
super(ID);
|
super(ID);
|
||||||
_caption = UIString.fromId("TITLE_OPEN_FILE"c).value;
|
_caption = UIString.fromId("TITLE_OPEN_FILE"c).value;
|
||||||
|
|
|
@ -37,7 +37,10 @@ class InputBox : Dialog {
|
||||||
_editor = new EditLine("inputbox_editor");
|
_editor = new EditLine("inputbox_editor");
|
||||||
_editor.layoutWidth = FILL_PARENT;
|
_editor.layoutWidth = FILL_PARENT;
|
||||||
_editor.text = _text;
|
_editor.text = _text;
|
||||||
_editor.editorAction.connect(&onEditorAction);
|
_editor.enterKey = delegate (EditWidgetBase editor) {
|
||||||
|
close(_buttonActions[_defaultButtonIndex]);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
_editor.contentChange = delegate(EditableContent content) {
|
_editor.contentChange = delegate(EditableContent content) {
|
||||||
_text = content.text;
|
_text = content.text;
|
||||||
};
|
};
|
||||||
|
@ -46,14 +49,6 @@ class InputBox : Dialog {
|
||||||
addChild(createButtonsPanel(_actions, _defaultButtonIndex, 0));
|
addChild(createButtonsPanel(_actions, _defaultButtonIndex, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool onEditorAction(const Action action) {
|
|
||||||
if (action.id == EditorActions.InsertNewLine) {
|
|
||||||
close(_buttonActions[_defaultButtonIndex]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// called after window with dialog is shown
|
/// called after window with dialog is shown
|
||||||
override void onShow() {
|
override void onShow() {
|
||||||
super.onShow();
|
super.onShow();
|
||||||
|
|
|
@ -1942,10 +1942,16 @@ interface EditorActionHandler {
|
||||||
bool onEditorAction(const Action action);
|
bool onEditorAction(const Action action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EnterKeyHandler {
|
||||||
|
bool onEnterKey(EditWidgetBase editor);
|
||||||
|
}
|
||||||
|
|
||||||
/// single line editor
|
/// single line editor
|
||||||
class EditLine : EditWidgetBase {
|
class EditLine : EditWidgetBase {
|
||||||
|
|
||||||
Signal!EditorActionHandler editorAction;
|
Signal!EditorActionHandler editorAction;
|
||||||
|
/// handle Enter key press inside line editor
|
||||||
|
Signal!EnterKeyHandler enterKey;
|
||||||
|
|
||||||
/// empty parameter list constructor - for usage by factory
|
/// empty parameter list constructor - for usage by factory
|
||||||
this() {
|
this() {
|
||||||
|
@ -2094,6 +2100,16 @@ class EditLine : EditWidgetBase {
|
||||||
|
|
||||||
/// handle keys
|
/// handle keys
|
||||||
override bool onKeyEvent(KeyEvent event) {
|
override bool onKeyEvent(KeyEvent event) {
|
||||||
|
if (enterKey.assigned) {
|
||||||
|
if (event.keyCode == KeyCode.RETURN && event.modifiers == 0) {
|
||||||
|
if (event.action == KeyAction.KeyDown)
|
||||||
|
return true;
|
||||||
|
if (event.action == KeyAction.KeyUp) {
|
||||||
|
if (enterKey(this))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.onKeyEvent(event);
|
return super.onKeyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
v0.9.132
|
v0.9.133
|
Loading…
Reference in New Issue