Re: Widget help needed...



On Tue, 2003-05-20 at 19:40, Bruno Tavares wrote:
I need a way to know if a widget has been visible for more than X
seconds.
Any sugestions. ( an event or sgnal would be great :) )


there's no such timer so far as i know, but it's easy to catch the
widget becoming visible and install a timeout for however many
milliseconds you want.  for example:


        $widget = ....->new...;

        $widget->signal_connect (map_event => sub {
                # this sub will be called when the window is
                # initially mapped, which is X-speak for "shown."
                Glib::Timeout->add ($nmilliseconds, sub {
                                # widget has been visible for 
                                # $nmilliseconds, do something about it.
                                0; # return false so we don't run again
                                });
                0;
                });

        $widget->show;

        # go on about your business....


i chose map-event rather than map because (so far as i can tell)
map-event is the one that gets called *after* the window is visible.


-- 
muppet <scott at asofyet dot org>




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