Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Gtk2::Entry scroll-event

by laybrother (Initiate)
on Aug 31, 2012 at 17:35 UTC ( #991052=perlquestion: print w/ replies, xml ) Need Help??
laybrother has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

How can I distinguish between roll-up and roll-down in a Gtk2::Entry->signal_connect('scroll-event' => sub ?

Thanks in advance

Comment on Gtk2::Entry scroll-event
Re: Gtk2::Entry scroll-event
by Anonymous Monk on Sep 01, 2012 at 00:03 UTC
    interrogate the event object :)

      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 ?

      my $imp_entry = Gtk2::Entry->new_with_max_length( 6 ) ; ... $imp_entry->signal_connect( 'scroll-event' => sub { # if($imp_entry->scroll-event->direction() eq 'up'){} !?!? $imp_entry->set_text( $imp_entry->get_text() + 0.05 ) ; } ) ;
      i.e.: as in the Gtk2::Gdk::Event::Scroll doc :
      METHODS ... scrolldirection = $eventscroll->direction ($newvalue=0)
      What $eventscroll ? Thanks for your attention.

        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 http://search.cpan.org/grep?cpanid=TSCH&release=Gtk2-1.245&string=event&i=1&n=1&C=0 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://991052]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2014-10-01 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (386 votes), past polls