migration to shorter listener names

This commit is contained in:
Vadim Lopatin 2015-04-14 13:20:39 +03:00
parent e34cf65351
commit 8190530136
8 changed files with 59 additions and 24 deletions

View File

@ -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;
};

View File

@ -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"));

View File

@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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)

View File

@ -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) {