Re: Tabbing out of a GtkText widget
| From: | (PHPDiscuss - PHP Newsgroups and mailing lists) | Date: | Fri, 16 Jul 2004 11:31:17 +0000 |
| Subject: | Re: Tabbing out of a GtkText widget | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-4757@lists.php.net to get a copy of this message | ||
I've done this by adding keypress handlers which manually set the focus to
the next/previous widget. It's not ideal, but it works:
class mything {
function init() {
/* $this->intro is a gtktext widget */
$this->intro->connect("key-press-event", array(&$this,
"intro_keypressed"));
}
function intro_keypressed($widget, $event) {
if (in_array($event->keyval, array(GDK_KEY_Tab,
GDK_KEY_ISO_Left_Tab))) {
if ($event->state & GDK_SHIFT_MASK) {
$this->newAuthorName->grab_focus();
}
else {
$this->linkText->grab_focus();
}
$widget->emit_stop_by_name('key-press-event');
return true;
}
return false;
}
}
the emit_stop_by_name is needed to prevent other handlers in the chain
from handling the event (without it, the focus changes, but a tab gets
inserted as well).
David Heath
Andrᅵ jansen wrote:
> Hi all,
> I'm using GtkText widgets in several places in my applications, mostly as
> "comment" fields.
> One thing I haven't been able to figure out yet is how to get out of a
> GtkText widget. The default navigation keys Tab and Up/Down Arrow will
> not work for me here.
> As expected , Tab inserts a tab character.
> Also as expected, Shift-Tab moves focus to the *previous* widget.
> Ctrl-Tab *also* inserts a Tab character.
> Alt-Tab is a system wide hotkey in Windows...
> Up and Down arrows simply (attempt to) move the cursor around inside the
> GtkText widget.
> $o how do I move keyboard focus to the widget following a GtkText
> *without* using the mouse?
> Any suggestions appreciated...
> regards,
> --
> Andrᅵ
> ===========================================================I'm out of my
mind, but feel free to leave a message...