Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^3: Gtk2::Entry scroll-event

by Anonymous Monk
on Sep 01, 2012 at 07:40 UTC ( #991132=note: print w/replies, xml ) Need Help??

in reply to Re^2: Gtk2::Entry scroll-event
in thread Gtk2::Entry scroll-event

I'm trying to reach this event object. Navigating the documentation is beeing a little bit difficult. Somebody can give me a hint about how can I refer to a not explicitly instantiated event ?

I imagine it would be covered in some introductory tutorial (even if it is for the c++)

Luckily showed

110: # warn Gtk2->get_current_event;

Which worked for me

#!/usr/bin/perl -- use Gtk2 -init; # Gtk2->init; works if you didn't use -init on use my $window = Gtk2::Window->new ('toplevel'); my $button = Gtk2::Button->new ('Quit'); $button->signal_connect (clicked => sub { warn "@_"; warn Gtk2::Gdk::Event->get; warn Gtk2->get_current_event; Gtk2->main_quit }); $window->add ($button); $window->show_all; Gtk2->main; __END__ Gtk2::Button=HASH(0xc6f164) at - line 7. Warning: something's wrong at - line 8. Gtk2::Gdk::Event::Key=SCALAR(0xa18d94) at - line 9.

Replies are listed 'Best First'.
Re^4: Gtk2::Entry scroll-event
by Anonymous Monk on Sep 01, 2012 at 07:41 UTC
    103:isa_ok ($event = Gtk2::Gdk::Event->new ('scroll'), 104: 'Gtk2::Gdk::Event::Scroll', 'Gtk2::Gdk::Event->new scroll'); 106:$event->direction ('down'); 107:is ($event->direction, 'down', '$scroll_event->direction'); 109:$event->device ($device);
Re^4: Gtk2::Entry scroll-event
by laybrother (Initiate) on Sep 01, 2012 at 08:11 UTC
    Fine! it is!
    $imp_entry->signal_connect( 'scroll-event' => sub { my $eventscroll = Gtk2->get_current_event ; my $scrolldirection = $eventscroll->direction() ; if( $scrolldirection eq 'up' ) { $imp_entry->set_text( $imp_entry->get_text() - 1 ) ; } elsif( $scrolldirection eq 'down' ) { $imp_entry->set_text( $imp_entry->get_text() + 1 ) ; } return FALSE ; } ) ;
    Thank You very much, Your Anonymous Wisdom, and all the Fatherhood.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991132]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2018-02-26 00:43 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (316 votes). Check out past polls.