mirror of https://github.com/buggins/dlangui.git
Mouse wheel support in lists and tree widget
This commit is contained in:
parent
3c371caa5a
commit
040b9233d7
|
@ -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++) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue