[Fxruby-users] Proper way to display a right-click context menu
Status: Inactive
Brought to you by:
lyle
|
From: Matthew M. <nam...@na...> - 2004-03-03 00:21:00
|
Hi everyone,
I'm still learning and have a new question ;) I want my file manager application
to display a menu when an item in a FXList is right-clicked. The menu displays
fine, but once it is displayed my window manager freezes up and I have to go
to a console and kill my application, after which my X session is back to normal.
Here are the relevant parts from the initialize method in my FXWindow subclass. I
can post the whole thing if necessary.
@rightClickMenu = FXMenuPane.new( self )
FXMenuCommand.new( @rightClickMenu, "Cut\tCtl-X" ).
connect( SEL_COMMAND, method(:cmdCut))
FXMenuCommand.new( @rightClickMenu, "Copy\tCtl-C" ).
connect( SEL_COMMAND, method(:cmdCopy))
FXMenuCommand.new( @rightClickMenu, "Paste\tCtl-V" ).
connect( SEL_COMMAND, method(:cmdPaste))
FXMenuCommand.new( @rightClickMenu, "Rename\tF2" ).
connect( SEL_COMMAND, method(:cmdRename))
@list.connect( SEL_RIGHTBUTTONPRESS, method(:cmdRightButtonPress))
Other class methods:
def cmdRightButtonPress( sender, sel, event )
if @rightClickMenu.shown
# @rightClickMenu.hide
@rightClickMenu.popdown
end
@rightClickMenu.popup( getParent(),
event.win_x + self.getX, event.win_y + self.getY )
end
def onSelect( sender, sel, event )
@selectedIndex = event
if @ctrlPressed
@selectedItems << @selectedIndex
else
@selectedItems.clear
end
if @rightClickMenu.shown
@rightClickMenu.popdown
end
end
Currently the methods given to FXMenuCommand only call @rightClickMenu.popdown
and exit. I've looked at the C++ source for FXMenuTitle and it was some help; I
learned of the popup and popdown methods. The statements that are shown in that
file for using grap and ungrap methods doesn't work, undefined method errors are
returned.
Well, any insight or pointers to an example would be very helpful.
Take care, Matthew.
--
"[In] my era everybody smoked and everybody drank and there was no
drug use" -- DEA Chief Thomas Constantine, July 1, 1998
|