mirror of https://github.com/buggins/dlangui.git
Add double click action
This commit is contained in:
parent
7ef1b7e809
commit
3195cc703f
|
@ -82,6 +82,12 @@ interface OnClickHandler {
|
||||||
bool onClick(Widget source);
|
bool onClick(Widget source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Interface slot for OnDoubleClick
|
||||||
|
interface OnDoubleClickHandler
|
||||||
|
{
|
||||||
|
bool onDoubleClick(Widget source);
|
||||||
|
}
|
||||||
|
|
||||||
/// interface - slot for onCheckChanged
|
/// interface - slot for onCheckChanged
|
||||||
interface OnCheckHandler {
|
interface OnCheckHandler {
|
||||||
bool onCheckChanged(Widget source, bool checked);
|
bool onCheckChanged(Widget source, bool checked);
|
||||||
|
@ -1172,6 +1178,14 @@ public:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called to process double click and notify listeners
|
||||||
|
protected bool handleDoubleClick()
|
||||||
|
{
|
||||||
|
if (doubleClick.assigned)
|
||||||
|
return doubleClick(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cancelLayout() {
|
void cancelLayout() {
|
||||||
_needLayout = false;
|
_needLayout = false;
|
||||||
|
@ -1278,11 +1292,16 @@ public:
|
||||||
setState(State.Pressed);
|
setState(State.Pressed);
|
||||||
if (canFocus)
|
if (canFocus)
|
||||||
setFocus();
|
setFocus();
|
||||||
|
nextClickIsDouble = event.doubleClick;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.action == MouseAction.ButtonUp && event.button == MouseButton.Left && state & State.Pressed) {
|
if (event.action == MouseAction.ButtonUp && event.button == MouseButton.Left && state & State.Pressed) {
|
||||||
resetState(State.Pressed);
|
resetState(State.Pressed);
|
||||||
|
if(nextClickIsDouble)
|
||||||
|
handleDoubleClick();
|
||||||
|
else
|
||||||
handleClick();
|
handleClick();
|
||||||
|
nextClickIsDouble = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.action == MouseAction.FocusOut || event.action == MouseAction.Cancel) {
|
if (event.action == MouseAction.FocusOut || event.action == MouseAction.Cancel) {
|
||||||
|
@ -1339,6 +1358,9 @@ public:
|
||||||
/// on click event listener (bool delegate(Widget))
|
/// on click event listener (bool delegate(Widget))
|
||||||
Signal!OnClickHandler click;
|
Signal!OnClickHandler click;
|
||||||
|
|
||||||
|
/// On double click event listener (bool delegate(Widget))
|
||||||
|
Signal!OnDoubleClickHandler doubleClick;
|
||||||
|
|
||||||
/// checked state change event listener (bool delegate(Widget, bool))
|
/// checked state change event listener (bool delegate(Widget, bool))
|
||||||
Signal!OnCheckHandler checkChange;
|
Signal!OnCheckHandler checkChange;
|
||||||
|
|
||||||
|
@ -1764,6 +1786,9 @@ public:
|
||||||
mixin(generatePropertySetters("margins", "padding"));
|
mixin(generatePropertySetters("margins", "padding"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool nextClickIsDouble = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Widget list holder. */
|
/** Widget list holder. */
|
||||||
|
|
Loading…
Reference in New Issue