Hi, I''m using FXRuby 1.0 on Windows. I''d like to display a popup menu after a right click on a tree item, I cannot make it work : #-------------------- root = FXTreeList.new(parent, 1, self, 0) pop = FXMenuPane.new(parent) expandCmd = FXMenuCommand.new(pop, "Expand", nil, app) expandCmd.connect(SEL_COMMAND) { root.currentItem.expanded=(true) } root.connect(SEL_RIGHTBUTTONRELEASE) do |sender, selector, data| pop.popup(root, data.rootclick_x, data.rootclick_y) end #--------------------- The same kind of code works with a FXTabItem instead of FXTreeItem. Would FXRuby 1.2 change something ? Thanks Thomas Acc?dez au courrier ?lectronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,34?/mn) ; t?l : 08 92 68 13 50 (0,34?/mn)
On Aug 5, 2005, at 1:08 PM, thom01 wrote:> I''d like to display a popup menu after a right click on a tree > item, I cannot make it work :<snip> This is the typical pattern I''d use for a right-click popup menu on a tree item (or whatever); treelist.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, evt| # Construct the menu pane popupMenu = FXMenuPane.new(parent) # Add some menu items... FXMenuCommand.new(popupMenu, "One") FXMenuCommand.new(popupMenu, "Two") # Create it popupMenu.create # Show it popupMenu.popup(nil, evt.root_x, evt.root_y) # Restrict to this window while shown... app.runModalWhileShown(popupMenu) end I just confirmed that this works in FXRuby 1.2, but I don''t know why it wouldn''t also work in FXRuby 1.0. Hope this helps, Lyle
Hi Lyle Thanks a lot, your example helped me to solve my problem. I''m a little confused with the create function :> # Create it > popupMenu.createI have a menu bar in my application, I don''t have to call create to display a menu pane from it. Maybe because the menu bar is part of the main window, and menus are created before calling FXMainWindow.show or FXApp.create ? I think I have the same kind of problem to add a new tab item to a tabbook. If you have time, could you complete the tabbook example (http://www.fxruby.org/examples/tabbook.rb) by adding an Add/Remove tab menu option ? Thanks Thomas Vanier> On Aug 5, 2005, at 1:08 PM, thom01 wrote: > > > I''d like to display a popup menu after a right click on a tree > > item, I cannot make it work : > > <snip> > > This is the typical pattern I''d use for a right-click popupmenu on a> tree item (or whatever); > > treelist.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, evt| > # Construct the menu pane > popupMenu = FXMenuPane.new(parent) > > # Add some menu items... > FXMenuCommand.new(popupMenu, "One") > FXMenuCommand.new(popupMenu, "Two") > > # Create it > popupMenu.create > > # Show it > popupMenu.popup(nil, evt.root_x, evt.root_y) > > # Restrict to this window while shown... > app.runModalWhileShown(popupMenu) > end > > I just confirmed that this works in FXRuby 1.2, but I don''tknow why it> wouldn''t also work in FXRuby 1.0. > > Hope this helps, > > Lyle > >Acc?dez au courrier ?lectronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,34?/mn) ; t?l : 08 92 68 13 50 (0,34?/mn)
On Wed, 17 Aug 2005 14:54:56 +0200, "thom01" <thom01@laposte.net> wrote :> Thanks a lot, your example helped me to solve my problem. > I''m a little confused with the create function : > > # Create it > > popupMenu.create > > I have a menu bar in my application, I don''t have to call > create to display a menu pane from it. > Maybe because the menu bar is part of the main window, and > menus are created before calling FXMainWindow.show or > FXApp.create?Yes, exactly. There''s a question in the FOX FAQ list (at http://www.fox-toolkit.com/faq.html) about the whole issue of when it''s necessary to call create() on a newly constructed window, or icon, or whatever.> I think I have the same kind of problem to add a new tab item > to a tabbook.Could be.> If you have time, could you complete the tabbook example > (http://www.fxruby.org/examples/tabbook.rb) by adding an > Add/Remove tab menu option?I''ve added this to the list of FXRuby feature requests: http://rubyforge.org/tracker/index.php?group_id=300&atid=1226 Hope this helps, Lyle