www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - gtkd ,drawingarea, capture mouse pressed

reply Alain De Vos <devosalain ymail.com> writes:
On a gtkd drawingarea I want to capture the mouse-pressed event 
and get the coordinates of the pointer on the area.
I have
```
addEvents(GdkEventMask.BUTTON_PRESS_MASK);
```
Maybe I must add a signal-handler ?
May 21 2021
parent reply evilrat <evilrat666 gmail.com> writes:
On Friday, 21 May 2021 at 12:28:36 UTC, Alain De Vos wrote:
 On a gtkd drawingarea I want to capture the mouse-pressed event 
 and get the coordinates of the pointer on the area.
 I have
 ```
 addEvents(GdkEventMask.BUTTON_PRESS_MASK);
 ```
 Maybe I must add a signal-handler ?
Not a gtk user, but maybe this will help (has quite a list of examples on gtkd, newest first) https://gtkdcoding.com/
May 21 2021
parent reply Alain De Vos <devosalain ymail.com> writes:
I'll have a look at that website.
With this code I capture the mouse press event

```
this()
{
addEvents(GdkEventMask.BUTTON_PRESS_MASK);
addOnDraw(&drawCallback);
addOnButtonPress(&onButtonPress);
}

```

```
public bool onButtonPress(Event event, Widget widget)
{
writeln("Button pressed");
return false;
}
```

But I still need the coordinates of pointer.
May 21 2021
parent reply drug <drug2004 bk.ru> writes:
21.05.2021 15:39, Alain De Vos пишет:
 I'll have a look at that website.
 With this code I capture the mouse press event
 
 ```
 this()
 {
 addEvents(GdkEventMask.BUTTON_PRESS_MASK);
 addOnDraw(&drawCallback);
 addOnButtonPress(&onButtonPress);
 }
 
 ```
 
 ```
 public bool onButtonPress(Event event, Widget widget)
 {
 writeln("Button pressed");
 return false;
 }
 ```
 
 But I still need the coordinates of pointer.
 
I'm not gtk user too but you could try to use GdkEventMask.BUTTON_MOTION_MASK to get pointer motion events while some button is pressed
May 21 2021
parent Alain De Vos <devosalain ymail.com> writes:
I found something,
https://api.gtkd.org/gdk.Event.Event.getCoords.html
May 21 2021