mirror of https://github.com/buggins/dlangui.git
mouse events
This commit is contained in:
parent
7328b2a662
commit
8df36ce12a
|
@ -25,11 +25,41 @@ enum MouseFlag : ushort {
|
||||||
XButton2= 0x0040
|
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 {
|
class MouseEvent {
|
||||||
protected MouseAction _action;
|
protected MouseAction _action;
|
||||||
protected ushort _flags;
|
protected ushort _flags;
|
||||||
protected short _x;
|
protected short _x;
|
||||||
protected short _y;
|
protected short _y;
|
||||||
|
protected ButonDetails _lbutton;
|
||||||
|
protected ButonDetails _mbutton;
|
||||||
|
protected ButonDetails _rbutton;
|
||||||
@property MouseAction action() { return _action; }
|
@property MouseAction action() { return _action; }
|
||||||
@property ushort flags() { return _flags; }
|
@property ushort flags() { return _flags; }
|
||||||
@property short x() { return _x; }
|
@property short x() { return _x; }
|
||||||
|
|
|
@ -306,8 +306,17 @@ class Win32Window : Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ButonDetails _lbutton;
|
||||||
|
protected ButonDetails _mbutton;
|
||||||
|
protected ButonDetails _rbutton;
|
||||||
|
|
||||||
override bool onMouseEvent(MouseEvent event) {
|
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);
|
Log.d("MouseEvent ", event.action, " flags=", event.flags, " x=", event.x, " y=", event.y);
|
||||||
|
if (event.action == MouseAction.LButtonDown)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue