mirror of https://github.com/buggins/dlangui.git
support mouse wheel in lists
This commit is contained in:
parent
fc8f1724af
commit
3f19e21478
|
@ -737,7 +737,7 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
if (window !is null) {
|
if (window !is null) {
|
||||||
if (window.onMouse(message, cast(ushort)wParam, cast(short)(lParam & 0xFFFF), cast(short)((lParam >> 16) & 0xFFFF)))
|
if (window.onMouse(message, cast(uint)wParam, cast(short)(lParam & 0xFFFF), cast(short)((lParam >> 16) & 0xFFFF)))
|
||||||
return 0; // processed
|
return 0; // processed
|
||||||
}
|
}
|
||||||
// not processed - default handling
|
// not processed - default handling
|
||||||
|
|
|
@ -584,6 +584,21 @@ class ScrollBar : AbstractSlider, OnClickHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// handle mouse wheel events
|
||||||
|
override bool onMouseEvent(MouseEvent event) {
|
||||||
|
if (visibility != Visibility.Visible)
|
||||||
|
return false;
|
||||||
|
if (event.action == MouseAction.Wheel) {
|
||||||
|
int delta = event.wheelDelta;
|
||||||
|
if (delta > 0)
|
||||||
|
sendScrollEvent(ScrollAction.LineUp, position);
|
||||||
|
else if (delta < 0)
|
||||||
|
sendScrollEvent(ScrollAction.LineDown, position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onMouseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
/// Draw widget at its position to buffer
|
/// Draw widget at its position to buffer
|
||||||
override void onDraw(DrawBuf buf) {
|
override void onDraw(DrawBuf buf) {
|
||||||
if (visibility != Visibility.Visible)
|
if (visibility != Visibility.Visible)
|
||||||
|
|
|
@ -519,6 +519,10 @@ class ListWidget : WidgetGroup, OnScrollHandler {
|
||||||
setHoverItem(-1);
|
setHoverItem(-1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// delegate processing of mouse wheel to scrollbar widget
|
||||||
|
if (event.action == MouseAction.Wheel && _needScrollbar) {
|
||||||
|
return _scrollbar.onMouseEvent(event);
|
||||||
|
}
|
||||||
// support onClick
|
// support onClick
|
||||||
Rect rc = _pos;
|
Rect rc = _pos;
|
||||||
applyMargins(rc);
|
applyMargins(rc);
|
||||||
|
|
Loading…
Reference in New Issue