Re: pop menu with a right-click in a gtktreeview



So th 3 is right click, I assume that 1 is the left and 2 the middle.
with $event->state i detect shift,alt,... also in numerical order? or how?

Another thing, you put :
  my ($treeview, $event) = @_;

How you know which are the arguments of this signal?

On Wed, Jun 25, 2008 at 3:06 AM, Kevin Ryde <user42 zip com au> wrote:
anguila <anguila gmail com> rites:
>
> I want to put a popup menu in a gtktreeview widget with a right-click of the
> mouse, and I'm wonder how can I detect if I'm clicking with the right or the
> left mouse click.

$event->button.  And if you want Shift/Alt/etc keys then $event->state.

> to put this menu in the position of the right click?

$menu->popup.

I use the following in my treeview (I update some stuff based on the
item under the mouse from $treeview->get_path_at_pos too).


$treeview->signal_connect (button_press_event => \&_do_menu_popup);

sub _do_menu_popup {
 my ($treeview, $event) = @_;
 if ($event->button != 3) {  # ignore other than button3
   return 0;  # propagate event
 }

 ...
 my ($path, $col, $cell_x, $cell_y)
   = $treeview->get_path_at_pos ($event->x, $event->y);
 ...

 $menu->popup (undef, undef, undef, undef, $event->button, $event->time);
 return 0; # propagate event
}



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