mirror of https://github.com/buggins/dlangui.git
move Mouse Wheel handler from tree to base class -- scroll widget
This commit is contained in:
parent
040b9233d7
commit
e9e99d6bf5
|
@ -134,6 +134,24 @@ class ScrollWidgetBase : WidgetGroup, OnScrollHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// process mouse event; return true if event is processed by widget.
|
||||||
|
override bool onMouseEvent(MouseEvent event) {
|
||||||
|
if (event.action == MouseAction.Wheel) {
|
||||||
|
if (event.flags == MouseFlag.Shift) {
|
||||||
|
if (_hscrollbar) {
|
||||||
|
_hscrollbar.sendScrollEvent(event.wheelDelta > 0 ? ScrollAction.LineUp : ScrollAction.LineDown);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (event.flags == 0) {
|
||||||
|
if (_vscrollbar) {
|
||||||
|
_vscrollbar.sendScrollEvent(event.wheelDelta > 0 ? ScrollAction.LineUp : ScrollAction.LineDown);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onMouseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
/// handle scroll event
|
/// handle scroll event
|
||||||
override bool onScrollEvent(AbstractSlider source, ScrollEvent event) {
|
override bool onScrollEvent(AbstractSlider source, ScrollEvent event) {
|
||||||
if (source.orientation == Orientation.Horizontal) {
|
if (source.orientation == Orientation.Horizontal) {
|
||||||
|
|
|
@ -667,8 +667,8 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh
|
||||||
protected bool _needUpdateWidgetStates;
|
protected bool _needUpdateWidgetStates;
|
||||||
|
|
||||||
protected bool _noCollapseForSingleTopLevelItem;
|
protected bool _noCollapseForSingleTopLevelItem;
|
||||||
@property bool noCollapseForSingleTopLevelItem() {
|
@property bool noCollapseForSingleTopLevelItem() {
|
||||||
return _noCollapseForSingleTopLevelItem;
|
return _noCollapseForSingleTopLevelItem;
|
||||||
}
|
}
|
||||||
@property TreeWidgetBase noCollapseForSingleTopLevelItem(bool flg) {
|
@property TreeWidgetBase noCollapseForSingleTopLevelItem(bool flg) {
|
||||||
_noCollapseForSingleTopLevelItem = flg;
|
_noCollapseForSingleTopLevelItem = flg;
|
||||||
|
@ -857,22 +857,6 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh
|
||||||
selectItem(item, makeVisible);
|
selectItem(item, makeVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// process mouse event; return true if event is processed by widget.
|
|
||||||
override bool onMouseEvent(MouseEvent event) {
|
|
||||||
if (event.action == MouseAction.Wheel) {
|
|
||||||
if (event.flags == MouseFlag.Control) {
|
|
||||||
if (_hscrollbar)
|
|
||||||
_hscrollbar.sendScrollEvent(event.wheelDelta > 0 ? ScrollAction.LineUp : ScrollAction.LineDown);
|
|
||||||
return true;
|
|
||||||
} else if (event.flags == 0) {
|
|
||||||
if (_vscrollbar)
|
|
||||||
_vscrollbar.sendScrollEvent(event.wheelDelta > 0 ? ScrollAction.LineUp : ScrollAction.LineDown);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.onMouseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
override protected bool handleAction(const Action a) {
|
override protected bool handleAction(const Action a) {
|
||||||
Log.d("tree.handleAction ", a.id);
|
Log.d("tree.handleAction ", a.id);
|
||||||
switch (a.id) with(TreeActions)
|
switch (a.id) with(TreeActions)
|
||||||
|
|
Loading…
Reference in New Issue