Re: Accelerator to close window
| From: | Madeleine D. | Date: | Fri, 21 Oct 2005 16:46:44 +0000 |
| Subject: | Re: Accelerator to close window | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6261@lists.php.net to get a copy of this message | ||
Benjamin-
You can do it with the event process. The example here is using the ESC
key, but the premise should be the same.
Bind the key-press-event to the window:
$win->connect("key_press_event", "PMwinEvent",
"PMWin_logon");
Then at the call back, verify the key selection:
function PMwinEvent(&$widget,$event,$source) {
if ($event->keyval == GDK_KEY_Escape) {
PMcloseWin($widget,$source);
}
}
Hope that helps.
Madeleine
At 10:47 AM 10/21/05 +0200, FOURTICQ Benjamin wrote:
>Hello,
>Is it possible to have a single GtkWindow and bind a key to close it. I
>mean without having any button nor menuitem, is it possible to bind
>Ctr-X to close a window ?
>
>I tried :
>
>$this->_accel_group = &new GtkAccelGroup();
>$this->dialog->add_accel_group ($this->_accel_group);
>$this->dialog->add_accelerator ("destroy", $this->_accel_group,
>GDK_KEY__x, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
>
>... But doesn't work
>
>$btnExit = new GtkButton(); // Button not visible
>$this->_accel_group = &new GtkAccelGroup();
>$this->dialog->add_accel_group ($this->_accel_group);
>$btnExit->add_accelerator ("clicked", $this->_accel_group, GDK_KEY__x,
>GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
>
>... But doesn't work
>
>Any idea ?
>Thanks in advance,
>Benjamin FOURTICQ.
>
>--
>PHP-GTK General Mailing List (http://gtk.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>