PHP-GTK
Saturday, September 20, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkWidget::activate
GtkWidget::add_eventsnext

Last updated: Sun, 12 May 2013
view this page in English

GtkWidget::add_accelerator

Adds an accelerator (shortcut key) for the widget, so that the button/widget can be accessed by using the keyboard, without moving the mouse or tabbing through widgets.

signal is the name of a signal that should be invoked on the widget once the accelerator is pressed. For a button, you most likely want to pass clicked here.

group is a GtkAccelGroup and should be the one set active for the window. Maybe you need to create the group and add it to the window first via add_accel_group() to be able to use it here.

accel_key defines the key to be pressed, see Symbolic names for keys to find the right one.

modifiers tells which additional button has to be pressed to emit the signal. Normally, you want to use Gdk::CONTROL_MASK (Ctrl key) or Gdk::MOD1_MASK (Alt key).

Example 149. Adding a shortcut for a button

//Our window
$wnd = new GtkWindow();
//Accelerator group
$group = new GtkAccelGroup();
//Add group to window, making it active
$wnd->add_accel_group($group);
 
//"back" button
$btn = GtkButton::new_from_stock(Gtk::STOCK_GO_BACK);
$btn->add_accelerator(
    'clicked', $group, Gdk::KEY_Left, Gdk::MOD1_MASK, 0
);
$wnd->add($btn);

In this example, you can use the shortcut Alt+Left to activate the back-button.

See also: remove_accelerator()


User Contributed Notes
gtk.gtkwidget.method.add_accelerator.php
add a note about notes
There are no user contributed notes for this page.


previousGtkWidget::activate
GtkWidget::add_eventsnext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:51:01 2013 CEST