support mouse wheel in lists

This commit is contained in:
Vadim Lopatin 2014-04-16 09:15:31 +04:00
parent fc8f1724af
commit 3f19e21478
3 changed files with 20 additions and 1 deletions

View File

@ -737,7 +737,7 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_RBUTTONUP:
case WM_MOUSEWHEEL:
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
}
// not processed - default handling

View File

@ -584,6 +584,21 @@ class ScrollBar : AbstractSlider, OnClickHandler {
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
override void onDraw(DrawBuf buf) {
if (visibility != Visibility.Visible)

View File

@ -519,6 +519,10 @@ class ListWidget : WidgetGroup, OnScrollHandler {
setHoverItem(-1);
return true;
}
// delegate processing of mouse wheel to scrollbar widget
if (event.action == MouseAction.Wheel && _needScrollbar) {
return _scrollbar.onMouseEvent(event);
}
// support onClick
Rect rc = _pos;
applyMargins(rc);