void add_mnemonic(int keyval, GtkWidget target );

Adds a mnemonic to the window. Whenever the mnemonic key is pressed, the target widget will be activated.

The keyval parameter is the ASCII number of the letter which shall cause the mnemonic to be activated. E.g. if you want Alt+K to activate a $button, the keyval would be
that is value 75 in ASCII.

Before the window gets destroyed, you have to remove the mnemonic by hand if you don't want a warning to be thrown.

Example 158. Adding a mnemonic by hand

//Create the window and the box for the buttons
$wnd = new GtkWindow();
$vbox = new GtkVBox();

//Button1 uses the easy method: An underscore before the
//desired mnemonic adds the mnemonic automatically
//Use Alt+1 to activate it
$button1 = new GtkButton('Button _1');

//Button2's mnemonic will be added by and, so we don't
//use an underscore here
$button2 = new GtkButton('Button 2');

//pack the widgets

//little echo method
function echoit($value) { echo $value . "\r\n"; }

//if one of the button is clicked, it's label will be printed
//on the console
$button1->connect_simple('clicked', 'echoit', $button1->get_label());
$button2->connect_simple('clicked', 'echoit', $button2->get_label());

//Here we add the mnemonic for button2 by hand. So
//pressing Alt+2 will cause button2 to be activated.
$wnd->add_mnemonic(ord('2'), $button2);

//We have to remove the mnemonic from the window before it gets destroyed
//If we don't do this, a warning will be spit out
$wnd->connect_simple('destroy', array($wnd, 'remove_mnemonic'), ord('2'), $button2);
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));


See also: remove_mnemonic()