Re: Gtk2: making a popup window on mouse click
- From: muppet <scott asofyet org>
- To: Jamie Lahowetz <deadpickle gmail com>
- Cc: gtk-perl-list gnome org
- Subject: Re: Gtk2: making a popup window on mouse click
- Date: Mon, 30 Jul 2007 21:16:29 -0400
On Jul 29, 2007, at 1:30 AM, Jamie Lahowetz wrote:
What I want to do is to have a the program run in a system tray.
when the user left clicks the system tray icon the window ('popup')
is set to show. Also, when the user left clicks on the system tray
the window is hidden again. How can I get this to work? I have a
small snippet of code that I a have started with:
[snip]
#handles tray clicks
sub click {
#left mouse button
if ($_[1]->button == 1) {
#Window show/hide controls
I think what you're looking for here is simply:
if ($control_window) {
$control_window->destroy;
$control_window = undef;
} else {
$control_window = make_control_window ();
$control_window->show;
}
}
#right mouse button
elsif ($_[1]->button == 3) {
&menu;
}
return 1;
}
#right click menu
sub menu {
[snip]
#popup menu, the three is for right mouse button
$menu->popup(undef,undef,undef,3,undef,undef);
It's best to use $event->time $event->button here instead of undef.
#Program interfaces
sub interface {
my $interface = Gtk2::Window->new('popup');
You almost certainly don't want 'popup'. For 99% of uses, you want
'toplevel'. A popup won't have window manager decorations, and will
generally annoy your user.
--
The one difference between Dali and a crazy man is very simple: Dali
is not crazy at all.
-- Salvador Dali
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]