Re: Gtk::perl documentation?

On Sat, 2003-04-19 at 13:08, Scott Russell wrote:
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.

you can still do bitwise comparisons in gtk-perl, and in fact, i believe
that for $event->{state} it's the only way.

in the past i've looked up the values of the masks in the headers and
defined constants in my app, but i'm sure there's another, better, way. 
at any rate, it works.  here's the relevant bits from a known-to-work
gtk-perl app:

    use constant GDK_CONTROL_MASK => (1 << 2);
    sub button1_down {
        my ($widget, $appwin, $event) = @_;

        if ($event->{state} & GDK_CONTROL_MASK) {

muppet <scott asofyet org>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]