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



anguila <anguila gmail com> writes:

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]