diff --git a/src/dlangui/core/events.d b/src/dlangui/core/events.d index 0370e790..24db5132 100644 --- a/src/dlangui/core/events.d +++ b/src/dlangui/core/events.d @@ -25,11 +25,41 @@ enum MouseFlag : ushort { XButton2= 0x0040 } +/// mouse button state details +struct ButtondDetails { + /// Clock.currStdTime() for down event of this button (0 if button is up). + long _downTs; + /// x coordinates of down event + short _downX; + /// y coordinates of down event + short _downY; + /// mouse button flags when down event occured + ushort _downFlags; + /// update for button down + void down(short x, short y, ushort flags) { + _downX = x; + _downY = y; + _downFlags = flags; + _downTs = std.datetime.Clock.currStdTime; + } + /// update for button up + void up() { + _downTs = 0; + _downX = 0; + _downY = 0; + _downFlags = 0; + } + @property bool isDown() { return downTs != 0; } +} + class MouseEvent { protected MouseAction _action; protected ushort _flags; protected short _x; protected short _y; + protected ButonDetails _lbutton; + protected ButonDetails _mbutton; + protected ButonDetails _rbutton; @property MouseAction action() { return _action; } @property ushort flags() { return _flags; } @property short x() { return _x; } diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index 30cdeff0..b2006b7f 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -306,8 +306,17 @@ class Win32Window : Window { } } + protected ButonDetails _lbutton; + protected ButonDetails _mbutton; + protected ButonDetails _rbutton; + override bool onMouseEvent(MouseEvent event) { + return false; + } + + bool onMouse(MouseEvent event) { Log.d("MouseEvent ", event.action, " flags=", event.flags, " x=", event.x, " y=", event.y); + if (event.action == MouseAction.LButtonDown) return true; } }