Re: Programmatically popup a tooltip



This doesn't seem very satisfactory, but despite a
good amount of searching I can't see how widgets and tooltips
interface with each other, so there seems not to be any easier
approach.

I tried a ugly hack like this...

my $TOOLTIP = Gtk2::Window->new('toplevel');
$TOOLTIP->set_decorated(0);
$TOOLTIP->set_type_hint('GDK_WINDOW_TYPE_HINT_DOCK'); # I don't if
this is the best hint
$TOOLTIP->add(Gtk2::Label->new('hello world'));
$TOOLTIP->set_default_size(100, 10);
$TOOLTIP->set_position('mouse');
$TOOLTIP->modify_bg ('normal', Gtk2::Gdk::Color->parse('yellow'));
....

my $image = Gtk2::Image->new_from_pixbuf (loaded from a png....)
my $ebox = Gtk2::EventBox->new;
$ebox->add ($image);
$ebox->add_events (['pointer-motion-mask', 'pointer-motion-hint-mask']);
$ebox->signal_connect ('motion-notify-event' => 
        sub {
                my ($widget, $event) = @_;
                my ($x, $y) = ($event->x, $event->y);
                if ($x > 10 && $x < 100 && $y > 10 && $y < 100) {
                        $TOOLTIP->show_all;
                } else {
                        $TOOLTIP->hide;
                }
        }
);


Two things that I absolutely hate about this are.

1. I don't like the location where the pop-up shows up. ('mouse') . I
wish that could be better.

2. Since this is another window altogether, it'll show up on my win32
taskbar (I guess same for other OS too). That's ugly for such an
insignificant tooltip popup window :)

Regards,

Ofey.



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