0

So im using gtkmm specifically here.

What I'm working on: I'm implementing a feature in which when I press in a certain window a parameter is increased/decreased depending on if the mouse moves left/right.

What needs to be done: To be able to somehow loop in the button press callback method -(doing so as each iteration would store the new value of the cursor position and compare it to the inital position to determine wheter increase value or decrease)- until the button is released.However the event which is sent remains the same so I cant just for example check to see if the events type becomes GTK_BUTTON_RELEASE. I have also tried to use a flag which is set to false in the button release call back, however the release callback isnt even called as the execution is stuck in the now infinite loop.

Thoughts Im thinking maybe the solution could be a certain something to do with signals.

Update: Gtk has two functions for doing what I was saying here exactly which are , gtk_events_pending(), and gtk_main_iteration(). Hever turns out having a limitless loop inside an event is considered a bad practise and its better to use other methods like here for example using GdkEventMotion, or other types.

  • 1
    I think what you want is more a GtkEventBox in which you will detect the position and the press/release from the user side. And let's say once a press was issued the position of the cursor will be tracked and executed until the user has released the press. If that's what you want, I think I can help you – Vladouch Jul 03 '22 at 19:43
  • I was recommended to use GdkEventMotion actually. Which I believe is also in the same general direction you were alluding to. Thanks ! – mourinhoAdamc Jul 04 '22 at 07:42

0 Answers0