Re: Hiding Popup Menus based on right clicks
- From: muppet <scott asofyet org>
- To: Ashwin Ramachandran <rashwin28 gmail com>
- Cc: gtk-perl-list gnome org
- Subject: Re: Hiding Popup Menus based on right clicks
- Date: Fri, 8 Dec 2006 21:49:12 -0500
On Dec 8, 2006, at 1:42 PM, Ashwin Ramachandran wrote:
I am not sure, if I need to use this API: $treeview->get_path_at_pos
($event->x, $event->y). This
gives me the x and y coordinates of the right clicked row. How do
I use this info and compare it
to the selected row?
Actually, it's exactly the other way around -- get_path_at_pos()
takes the click's coordinates and gives you back the path of the row
that at that x,y position (and possibly the column and coordinates
within the cell). You can then ask the treeview's selection if that
path is selected.
Warning: this code is completely untested:
$treeview->signal_connect (button_press_event => sub {
my ($treeview, $event) = @_;
if ($event->button == 3 # right click
&& $event->window = $treeview->get_bin_window) {
my $path = $treeview->get_path_at_pos ($event->x,
$event->y);
if ($treeview->get_selection->path_is_selected ($path)) {
show_my_context_menu (...);
}
}
return FALSE;
});
Now, the code there connects to button-press-event, but you can also
connect to button-release-event, which gives you the opportunity to
let the click change the selection before attempting to pop up the
context menu. Then you don't have to pull these tricks.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]