Mouse wheel support in lists and tree widget

This commit is contained in:
Vadim Lopatin 2016-01-18 10:07:58 +03:00
parent 3c371caa5a
commit 040b9233d7
2 changed files with 21 additions and 0 deletions

View File

@ -1085,6 +1085,11 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
} else {
scrollOffset.x = _scrollPosition;
}
if (event.action == MouseAction.Wheel) {
if (_scrollbar)
_scrollbar.sendScrollEvent(event.wheelDelta > 0 ? ScrollAction.LineUp : ScrollAction.LineDown);
return true;
}
if (event.action == MouseAction.ButtonDown && (event.flags & (MouseFlag.LButton || MouseFlag.RButton)))
setFocus();
for (int i = 0; i < itemCount; i++) {

View File

@ -857,6 +857,22 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh
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) {
Log.d("tree.handleAction ", a.id);
switch (a.id) with(TreeActions)