Key press events on buttons?



Hello,

I want to enable two buttons to be sensitive for key press events.
I've created this buttions like this

  button = gtk_button_new_with_label(Button 1);
  gtk_signal_connect(GTK_OBJECT(button), "clicked", Button1Callback, NULL);
  gtk_box_pack_start(GTK_BOX(main_vbox), button, FALSE, TRUE, 5);
  GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default(button);
  
  button = gtk_button_new_with_label(Button 2);
  gtk_signal_connect(GTK_OBJECT(button), "clicked", Button2Callback, NULL);
  gtk_box_pack_start(GTK_BOX(main_vbox), button, TRUE, TRUE, 5);
  GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);

The window comes up with the two buttons Button 1 is marked.
When I click with the mouse on button 2  Button2Callback is called
as everybody would expect.  But if I use the cursor keys to mark
Button 2 and then press enter, Button1Callback is called instead of
Button2Callback as I wanted to be :-((.
What do I have to do that Button 2 is selected via keyboard correctly?

Moreover is there an easy way to bind a key to the buttons, like in
item_factory?  Say an underlined _1 or _2 would cause a clicked
event on the respective button?

Kind regards

         Andreas.



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