digitalmars.D.learn - How do you get mouse movement info in GtkD?
- Enjoys Math (4/4) Jan 29 2016 I'm able to get the mouse click positions with event.button().x/y
- Enjoys Math (11/16) Jan 29 2016 I see now:
- Ron Tarrant (16/19) Dec 27 2018 I know this post is old, but a search I did the other day brought
I'm able to get the mouse click positions with event.button().x/y But what .x/y do you query inside of an onMotionNotify event handler? Thanks!
Jan 29 2016
On Saturday, 30 January 2016 at 06:33:55 UTC, Enjoys Math wrote:I'm able to get the mouse click positions with event.button().x/y But what .x/y do you query inside of an onMotionNotify event handler? Thanks!I see now: bool onMouseMove(GdkEventMotion* eventMotion, Widget widget) { //event.get writeln("Mouse move event in scene."); return true; } addOnMotionNotify(&onMouseMove) There's also one that takes an Event param, but there's no obvious way to get the x/y info from that so I'll just use this lower level one which seems to work.
Jan 29 2016
On Saturday, 30 January 2016 at 06:43:11 UTC, Enjoys Math wrote:There's also one that takes an Event param, but there's no obvious way to get the x/y info from that so I'll just use this lower level one which seems to work.I know this post is old, but a search I did the other day brought me here, so I'm assuming someone else may find this new info useful... I don't think this part of GtkD was abstracted down that far. Here's a solution I came up with (connect via addOnMotionNotify(&onMotion) if you're in the same context) public bool onMotion(Event event, Widget widget) { if(event.type == EventType.MOTION_NOTIFY) { writeln("x = ", event.motion.x, " y = ", event.motion.y); } return(true); } // onMotion()
Dec 27 2018