hi,
i got a problem with popup menus.
the popupmenu shows up on left mouseclick. if i move the cursor straight on over the menu it works.
but if i move the mouse out of the popupmenu on the canvas again - guess what - the whole application blocks.
FOX experienced fellows: please have a look at my (extremely simple) code. please tell me what’s wrong with my popup.
i have no clue how to solve this.
- meinrad
here is the code: (make sure to have a recent version of FXRuby istalled)
require 'fox’
require 'opengl’
include Fox
$stdout.sync = true
class GLAppWindow < FXMainWindow
def initialize(app)
super(app, "FX/OpenGL Application", nil, nil, DECOR_ALL, 0, 0, 800, 600)
panel = FXVerticalFrame.new(self, (FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT))
panel.padLeft, panel.padRight = 0, 0
panel.padTop, panel.padBottom = 0, 0
@canvas = FXCanvas.new(panel, self, 0,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT)
@mypopup = FXPopup.new(@canvas )
say_hello = FXMenuCommand.new(@mypopup, "say hello")
cancel = FXMenuCommand.new(@mypopup, "cancel")
say_hello.connect(SEL_COMMAND) { puts 'hello'; @mypopup.popdown }
cancel.connect(SEL_COMMAND) { puts 'bye'; @mypopup.popdown }
@canvas.connect(SEL_LEFTBUTTONPRESS) { |sender, sel, event|
@mypopup.popup(self, event.root_x, event.root_y)
}
@canvas.connect(SEL_PAINT,method( :onPaint ))
end
def onPaint(sender, sel, event)
dc = FXDCWindow.new(@canvas, event)
dc.setForeground(@canvas.backColor)
dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w, event.rect.h)
dc.end
end
def create
super
show(PLACEMENT_SCREEN)
end
end
application = FXApp.new(“GLTest”, “FoxTest”)
window = GLAppWindow.new(application)
application.create
application.run