Re: cancelling/aborting an emitted signal



>Hello,
>
>Can someone suggest the proper generic way to abort a signal from
>actually causing the default handler to change the widget value. Must I
>connect the signal handler in a certain order?
>
>For example, in a "toggled" signal handler for a toggle button if some
>condition is true then I want the "toggled" signal to be canceled so the
>widget does not signify the change (a checkmark displayed or removed).
>I've tried the following but get a Gtk Warning indicating there is to no
>emitted signal to stop:
>
>gtk_signal_emit_stop_by_name (GTK_OBJECT (button), "toggled");

catch the button_press_event and you'll probably find that you're in
better shape. also, check and double check that you're calling it on
the correct widget - i've sometimes done cut-n-paste ops that have led
to that error message.

>Again, I want to know the generic method to cancel a signal within a
>signal handler so the widget does not reflect the change. This applies
>to GtkAdjustment value changes (for GtkHScale and GtkSpinButton
>changes), GtkCList row selection and unselection, and others.

i do this a LOT in my code, and i always use
gtk_signal_emit_stop_by_name(), but i always catch the underlying
events (button press/release etc.), not the "translations" like
clicked/selected/activate and so forth.

you also need to still return TRUE, sometimes.

--p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]