Re: gtk_widget_event()
- From: Havoc Pennington <hp redhat com>
- To: Allin Cottrell <cottrell wfu edu>
- Cc: <gtk-list gnome org>
- Subject: Re: gtk_widget_event()
- Date: 10 Dec 2000 14:43:50 -0500
Allin Cottrell <cottrell wfu edu> writes:
> I'm trying to make a double-click on certain locations
> equivalent to clicking the "OK" button in a window.
The easiest way to do this is to just call gtk_widget_activate() on
the button. It won't animate though.
> I gather the right thing is to construct an appropriate GdkEvent
> and pass it to gtk_widget_event() along with a pointer to the OK
> button. But I'm having trouble getting the event right. Can
> anyone tell me legitimate values for the "state" and "button"
> fields in the GdkEventButton struct?
>
> Specifically, I've got as far as making the OK button look
> pressed momentarily by double-clicking, but the callback is
> failing to invoke the "click" event for the button and I suspect
> that's because my artificial event isn't quite right.
>
To simulate a single click, you need to send two events,
GDK_BUTTON_PRESS and GDK_BUTTON_RELEASE. "state" should be the active
modifiers, which you can get by calling gdk_window_get_pointer() (just
pass NULL for x/y since you don't care about them). Reminds me that we
should add gdk_get_keyboard_state() or something. "button" is 1 for
left button, 2 for middle, 3 for right.
To fully simulate an event's normal behavior, call gtk_main_do_event()
instead of gtk_widget_event(); then the event is potentially
propagated to multiple widgets as it normally would be.
To do a double click you have to add another BUTTON_PRESS and a
2BUTTON_PRESS. My book gives the order to send the events in the GDK
chapter someplace.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]