0

I am trying to write a function which will wait till the user clicks somewhere within a GTK+ widget (similar to a drawing area) and return mouse co-ordinates. This function should behave modally in that it waits till input is received. Those familiar with the Windows API may find some similarity to the TrackPopupMenu function which also waits till a menu item is selected.

What I am trying to do here is similar to running a "secondary message loop" using the Windows API. How is it done in GTK+?

Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217

2 Answers2

1

You can call gtk_main_iteration_do(FALSE); to "pump" the GTK+ event system, without (the FALSE) blocking the application.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • Are there any problems in calling gtk_main again followed by gtk_main_quit once the job is done? As an example, I want to write a function which prompts the user to select a point within the client area. I set up a signal handler for button-press-event and call gtk_main. In the handler, once the point is selected, I save the point somewhere and call gtk_main_quit causing the innermost gtk_main to return. Is this advisable? – Agnel Kurian May 24 '12 at 12:43
0

Being modal is possible for a GtkWindow, using gtk_window_set_modal, not for a GtkWidget. That makes sense, otherwise the user wouldn't know what to interact with if there wasn't a window poping up.

liberforce
  • 11,189
  • 37
  • 48
  • In this case, I am not using a modal window. I just want a function which behaves modally. The function prompts the user to select a point and does not return till the point is selected. – Agnel Kurian May 24 '12 at 12:45