mirror of https://github.com/buggins/dlangui.git
ComboEdit enhancements - issue #224
This commit is contained in:
parent
53e13ff706
commit
c32df24ad9
|
@ -49,6 +49,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
ComboEdit { id: ce1; text: "some text"; minWidth: 100; items: ["Item 1", "Item 2", "Additional item"] }
|
ComboEdit { id: ce1; text: "some text"; minWidth: 100; items: ["Item 1", "Item 2", "Additional item"] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EditBox { layoutWidth: 300; layoutHeight: 80 }
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
Button { id: btnOk; text: "Ok" }
|
Button { id: btnOk; text: "Ok" }
|
||||||
Button { id: btnCancel; text: "Cancel" }
|
Button { id: btnCancel; text: "Cancel" }
|
||||||
|
|
|
@ -118,6 +118,9 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
||||||
_button.layout(rc);
|
_button.layout(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void popupClosed() {
|
||||||
|
}
|
||||||
|
|
||||||
protected void showPopup() {
|
protected void showPopup() {
|
||||||
if (!_adapter || !_adapter.itemCount)
|
if (!_adapter || !_adapter.itemCount)
|
||||||
return; // don't show empty popup
|
return; // don't show empty popup
|
||||||
|
@ -138,6 +141,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
||||||
if (_popup !is null) {
|
if (_popup !is null) {
|
||||||
_popup.close();
|
_popup.close();
|
||||||
_popup = null;
|
_popup = null;
|
||||||
|
popupClosed();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -490,14 +494,29 @@ class ComboEdit : ComboBox {
|
||||||
focusable = false;
|
focusable = false;
|
||||||
clickable = false;
|
clickable = false;
|
||||||
_edit.focusable = true;
|
_edit.focusable = true;
|
||||||
keyEvent = delegate(Widget source, KeyEvent event) {
|
}
|
||||||
if (event.keyCode == KeyCode.DOWN) {
|
|
||||||
|
/// process key event, return true if event is processed.
|
||||||
|
override bool onKeyEvent(KeyEvent event) {
|
||||||
|
if (event.keyCode == KeyCode.DOWN && enabled) {
|
||||||
if (event.action == KeyAction.KeyDown) {
|
if (event.action == KeyAction.KeyDown) {
|
||||||
showPopup();
|
showPopup();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return _edit.onKeyEvent(event);
|
if ((event.keyCode == KeyCode.SPACE || event.keyCode == KeyCode.RETURN) && readOnly && enabled) {
|
||||||
};
|
if (event.action == KeyAction.KeyDown) {
|
||||||
|
showPopup();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (_edit.onKeyEvent(event))
|
||||||
|
return true;
|
||||||
|
return super.onKeyEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected void popupClosed() {
|
||||||
|
_edit.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// called to process click and notify listeners
|
// called to process click and notify listeners
|
||||||
|
|
|
@ -1624,6 +1624,12 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (event.keyCode == KeyCode.SPACE && !readOnly) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event.keyCode == KeyCode.RETURN && !readOnly && !_content.multiline) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return super.onKeyEvent(event);
|
return super.onKeyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1211,6 +1211,14 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((event.keyCode == KeyCode.SPACE || event.keyCode == KeyCode.RETURN)) {
|
||||||
|
if (event.action == KeyAction.KeyDown && enabled) {
|
||||||
|
if (itemEnabled(_selectedItemIndex)) {
|
||||||
|
itemClicked(_selectedItemIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return super.onKeyEvent(event);
|
return super.onKeyEvent(event);
|
||||||
//if (_selectedItemIndex != -1 && event.action == KeyAction.KeyUp && (event.keyCode == KeyCode.SPACE || event.keyCode == KeyCode.RETURN)) {
|
//if (_selectedItemIndex != -1 && event.action == KeyAction.KeyUp && (event.keyCode == KeyCode.SPACE || event.keyCode == KeyCode.RETURN)) {
|
||||||
// itemClicked(_selectedItemIndex);
|
// itemClicked(_selectedItemIndex);
|
||||||
|
|
Loading…
Reference in New Issue