From 8190530136ecb2f055da19b1e25dd2ea59d12207 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 14 Apr 2015 13:20:39 +0300 Subject: [PATCH] migration to shorter listener names --- README.md | 8 +++++--- examples/example1/src/example1.d | 12 ++++++------ src/dlangui/core/editable.d | 4 +++- src/dlangui/widgets/combobox.d | 4 +++- src/dlangui/widgets/editors.d | 12 +++++++++--- src/dlangui/widgets/grid.d | 9 +++++++-- src/dlangui/widgets/lists.d | 10 +++++++--- src/dlangui/widgets/widget.d | 24 +++++++++++++++++++----- 8 files changed, 59 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 6ab3748a..e5d290c8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ API Documentation: [http://buggins.github.io/dlangui/ddox](http://buggins.github Wiki: [https://github.com/buggins/dlangui/wiki/Home](https://github.com/buggins/dlangui/wiki/Home) +Getting Started Tutorial: [https://github.com/buggins/dlangui/wiki/Getting-Started](https://github.com/buggins/dlangui/wiki/Getting-Started) + Screenshots: [http://buggins.github.io/dlangui/screenshots.html](http://buggins.github.io/dlangui/screenshots.html) @@ -324,14 +326,14 @@ Example of complex UI easy created from text: auto edit1 = window.mainWidget.childById!EditLine("edit1"); auto edit2 = window.mainWidget.childById!EditLine("edit2"); // close window on Cancel button click - window.mainWidget.childById!Button("btnCancel").onClickListener = delegate(Widget w) { + window.mainWidget.childById!Button("btnCancel").click = delegate(Widget w) { window.close(); return true; }; // show message box with content of editors - window.mainWidget.childById!Button("btnOk").onClickListener = delegate(Widget w) { + window.mainWidget.childById!Button("btnOk").click = delegate(Widget w) { window.showMessageBox(UIString("Ok button pressed"d), - UIString("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text)); + UIString("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text)); return true; }; diff --git a/examples/example1/src/example1.d b/examples/example1/src/example1.d index eb367992..bca8ee1f 100644 --- a/examples/example1/src/example1.d +++ b/examples/example1/src/example1.d @@ -46,13 +46,13 @@ class TimerTest : HorizontalLayout { _start = new Button(null, "Start timer"d); _stop = new Button(null, "Stop timer"d); _stop.enabled = false; - _start.onClickListener = delegate(Widget src) { + _start.click = delegate(Widget src) { _start.enabled = false; _stop.enabled = true; timerId = setTimer(1000); return true; }; - _stop.onClickListener = delegate(Widget src) { + _stop.click = delegate(Widget src) { _start.enabled = true; _stop.enabled = false; cancelTimer(timerId); @@ -477,9 +477,9 @@ extern (C) int UIAppMain(string[] args) { ); destroy(w); - layout.childById("BTN1").onClickListener = (delegate (Widget w) { Log.d("onClick ", w.id); return true; }); - layout.childById("BTN2").onClickListener = (delegate (Widget w) { Log.d("onClick ", w.id); return true; }); - layout.childById("BTN3").onClickListener = (delegate (Widget w) { Log.d("onClick ", w.id); return true; }); + layout.childById("BTN1").click = delegate (Widget w) { Log.d("onClick ", w.id); return true; }; + layout.childById("BTN2").click = delegate (Widget w) { Log.d("onClick ", w.id); return true; }; + layout.childById("BTN3").click = delegate (Widget w) { Log.d("onClick ", w.id); return true; }; } @@ -531,7 +531,7 @@ extern (C) int UIAppMain(string[] args) { Button btn = new Button(null, "Add item"d); itemedit.addChild(btn); longLists.addChild(itemedit); - btn.onClickListener = delegate(Widget src) + btn.click = delegate(Widget src) { stringList.add(itemtext.text); listAdapter.add((new TextWidget()).text(itemtext.text).styleId("LIST_ITEM")); diff --git a/src/dlangui/core/editable.d b/src/dlangui/core/editable.d index f0fa1002..128fd8b9 100644 --- a/src/dlangui/core/editable.d +++ b/src/dlangui/core/editable.d @@ -586,7 +586,9 @@ class EditableContent { @property EditableContent smartIndentsAfterPaste(bool enabled) { _smartIndentsAfterPaste = enabled; return this; } /// listeners for edit operations - Signal!EditableContentListener contentChangeListeners; + Signal!EditableContentListener contentChanged; + /// contentChanged signal alias for backward compatibility; will be deprecated in future + alias contentChangeListeners = contentChanged; protected bool _multiline; /// returns true if miltyline content is supported diff --git a/src/dlangui/widgets/combobox.d b/src/dlangui/widgets/combobox.d index 3e3df886..a08c203a 100644 --- a/src/dlangui/widgets/combobox.d +++ b/src/dlangui/widgets/combobox.d @@ -45,7 +45,9 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler { protected int _selectedItemIndex; /** Handle item click. */ - Signal!OnItemSelectedHandler onItemClickListener; + Signal!OnItemSelectedHandler itemClick; + /// itemClick signal alias for backward compatibility; will be deprecated in future + alias onItemClickListener = itemClick; protected Widget createSelectedItemWidget() { Widget res; diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 8feccac9..a1aa3adc 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -241,9 +241,15 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction protected bool _contentChanged = true; - /// Modified state change listener - Signal!ModifiedStateListener onModifiedStateChangeListener; - Signal!EditableContentChangeListener onContentChangeListener; + /// Modified state change listener (e.g. content has been saved, or first time modified after save) + Signal!ModifiedStateListener modifiedStateChange; + /// modifiedStateChange signal alias for backward compatibility; will be deprecated in future + alias onModifiedStateChangeListener = modifiedStateChange; + + /// editor content is changed + Signal!EditableContentChangeListener contentChange; + /// contentChange signal alias for backward compatibility; will be deprecated in future + alias onContentChangeListener = contentChange; /// override to support modification of client rect after change, e.g. apply offset override protected void handleClientRectLayout(ref Rect rc) { diff --git a/src/dlangui/widgets/grid.d b/src/dlangui/widgets/grid.d index ac18bfe8..ccf9e664 100644 --- a/src/dlangui/widgets/grid.d +++ b/src/dlangui/widgets/grid.d @@ -228,9 +228,14 @@ interface CellActivatedHandler { /// Abstract grid widget class GridWidgetBase : ScrollWidgetBase { /// Callback to handle selection change - Listener!CellSelectedHandler onCellSelected; + Listener!CellSelectedHandler cellSelected; + /// cellSelected signal alias for backward compatibility; will be deprecated in future + alias onCellSelected = cellSelected; + /// Callback to handle cell double click - Listener!CellActivatedHandler onCellActivated; + Listener!CellActivatedHandler cellActivated; + /// cellActivated signal alias for backward compatibility; will be deprecated in future + alias onCellActivated = cellActivated; protected CustomGridCellAdapter _customCellAdapter; diff --git a/src/dlangui/widgets/lists.d b/src/dlangui/widgets/lists.d index 94476959..f6f9374f 100644 --- a/src/dlangui/widgets/lists.d +++ b/src/dlangui/widgets/lists.d @@ -393,9 +393,13 @@ interface OnItemClickHandler { class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler { /** Handle selection change. */ - Signal!OnItemSelectedHandler onItemSelectedListener; - /** Handle item click. */ - Signal!OnItemSelectedHandler onItemClickListener; + Signal!OnItemSelectedHandler itemSelected; + /// itemSelected signal alias for backward compatibility; will be deprecated in future + alias onItemSelectedListener = itemSelected; + /** Handle item click / activation (e.g. Space or Enter key press and mouse double click) */ + Signal!OnItemClickHandler itemClick; + /// itemClick signal alias for backward compatibility; will be deprecated in future + alias onItemClickListener = itemClick; protected Orientation _orientation = Orientation.Vertical; /// returns linear layout orientation (Vertical, Horizontal) diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index 2f0b58db..f1d77d33 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -1204,15 +1204,29 @@ class Widget { // Signals /// on click event listener (bool delegate(Widget)) - Signal!OnClickHandler onClickListener; + Signal!OnClickHandler click; + /// click signal alias for backward compatibility; will be deprecated in future + alias onClickListener = click; + /// checked state change event listener (bool delegate(Widget, bool)) - Signal!OnCheckHandler onCheckChangeListener; + Signal!OnCheckHandler checkChange; + /// checkChange signal alias for backward compatibility; will be deprecated in future + alias onCheckChangeListener = checkChange; + /// focus state change event listener (bool delegate(Widget, bool)) - Signal!OnFocusHandler onFocusChangeListener; + Signal!OnFocusHandler focusChange; + /// focusChange signal alias for backward compatibility; will be deprecated in future + alias onFocusChangeListener = focusChange; + /// key event listener (bool delegate(Widget, KeyEvent)) - return true if event is processed by handler - Signal!OnKeyHandler onKeyListener; + Signal!OnKeyHandler keyEvent; + /// keyEvent signal alias for backward compatibility; will be deprecated in future + alias onKeyListener = keyEvent; + /// mouse event listener (bool delegate(Widget, MouseEvent)) - return true if event is processed by handler - Signal!OnMouseHandler onMouseListener; + Signal!OnMouseHandler mouseEvent; + /// mouseEvent signal alias for backward compatibility; will be deprecated in future + alias onMouseListener = mouseEvent; /// helper function to add onCheckChangeListener in method chain Widget addOnClickListener(bool delegate(Widget) listener) {