Re: I want popup menus :(




On Jul 18, 2004, at 3:44 PM, ArtÅras Ålajus wrote:

i have treeview implemented thru simplelist and i want popup menus when pressing rightclick on item. any ideas what i should read to know how this works?

read the TreeView docs, and Gtk2::Menu for Gtk2::Menu::popup. you'll also want the Gtk2::Gdk::Event::Button.

basic procedure:

1. connect to the "button-press-event" on the treeview. if you want right-clicking to select the row before popping up the menu, use signal_connect_after() to connect to the button-press-event, so that the default handlers run first.
2. in the handler:
a) if $event->button==3 (the right mouse button), create your menu and call $menu->popup. the menu pos func can be undef unless you want to do something fancy. pass $event->button to popup() so that the menu tracks the correct mouse button. b) if you need to know which row the user clicked on: ($x, $y) = $event->coords tells you where the user clicked, and you can pass those to $treeview->get_path_at_pos to find the path, column, and cell coords of the click. c) remember that returning TRUE or FALSE from the handler controls whether the default handlers run.

--
The door is locked. I tried to open it, but the lock is harder to pick than a broken nose.
  -- Sensei, on 'I, Ninja'




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