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

Re: key_event causing toggle_button to change states



On Mon, 6 Aug 2001 09:34:28 -0700, Norris, Kendall P. said:

> I am trying to cause a toggle button to toggle using input from the
>  keyboard.  A key_press_event is trapped and calls the correct function.  I
>  tried using gtk_toggle_button_toggled but the toggle button does not change
>  states.  I then tried using the gtk_toggle_button_get_active in an if/else
>  statement and used gtk_toggle_button_set_active to set the button state.
>  The result using this code is a continuous state change and crashes the
>  process.  It acts like the key_press_event hangs and never clears.  This
>  looked simple but...

I'm not 100% sure what the problem is but I have some suggestions.

When you recieve the key event, you should toggle the
GtkToggleButton with:

GTK_TOGGLE_BUTTON(tb)->active = !GTK_TOGGLE_BUTTON(tb)->active;
gtk_signal_emit_by_name(GTK_OBJECT(tb), "toggled");

This will change the toggle and emit the signal, which in turn
will cause the toggle button to call the "toggled" signal
callback you have set.


-- 
--
Sincerely,		    ,"-_			 \|/
-Capt. Taura M. 	    ,	O=__			--X--
.__			     ,_JNMNNEO=_		 /|\
OMNOUMmnne.		     {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn. 	      'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe	       '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.		   "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.		  __  7EMMMNNNNNWWWEEEEEEEOO.	  " .
NNMMMMWWWMMMWEINMMMNn		 "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
		  http://furry.ao.net/~learfox/






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