Re: Gtk::perl documentation?
- From: Scott Russell <lnxgeek us ibm com>
- To: gtk-perl-list gnome org
- Subject: Re: Gtk::perl documentation?
- Date: 19 Apr 2003 13:08:07 -0400
On Wed, 2003-04-16 at 18:20, muppet wrote:
constants are handled as strings, for readability, and because it can happen
automagically thanks to the GType system. in general, strip the prefix,
lowercase it, and optionally convert _ to -:
GTK_WINDOW_TOPLEVEL => 'toplevel'
GTK_BUTTONS_OK_CANCEL => 'ok-cancel' (or 'ok_cancel')
flags are a special case. you can't bitwise-or strings, so you provide a
reference to an array of them instead. anonymous arrays are useful here, and
an empty anonymous array is a great way to say 'no flags'.
FOO_BAR_BAZ | FOO_BAR_QUU | FOO_BAR_QUUX => [qw/baz quu quux/]
0 => []
note that if you don't like the short form or aren't sure what it would be,
you can just stringify the full form, e.g.:
'GTK_WINDOW_TOPLEVEL' is equivalent to 'toplevel'
the _STOCK_ stuff is a little different; you actually give the stock id
string, e.g., GTK_STOCK_OK => 'gtk-ok'. i don't know where the docs are for
that, but it's been my first guess every time.
This bit here I think is key to an problem I'm working on.
I'm trying to properly handle the $event->{state} from a
key_press_event. I've seen references to using bitwise operations with
the constant CONTROL_MASK for example to check for the CTRL key. Direct
comparisons fail because the value of $event->{state} changes depending
on other keys, such as num lock or caps lock.
I'm having a hard time translating this to Gtk-Perl and so far have
found no examples (maybe I'm not searching right?). As a non working
example this tries to insert \n into a Gtk::Text widget on SHIFT-Return:
sub _keypress_entry {
my ($self, $widget, $event) = @_;
if ($event->{'state'} == 1 &&
($event->{'keyval'} == $Gtk::Keysyms{'Return'} {
my $pos = $widget->get_position();
$widget->insert_text("\n", $pos);
$widget->signal_emit_stop_by_name('key_press_event');
return 1;
}
}
The above works ONLY if no other modifier keys are being pressed and
num/caps/scroll lock are off.
Thanks for the help.
--
Scott Russell <lnxgeek us ibm com>
Linux Technology Center System Admin
http://ltc.linux.ibm.com/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]