FXRuby Popup problem (runnable script inside)

  • Thread starter Recheis Meinrad
  • Start date
R

Recheis Meinrad

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( :eek:nPaint ))
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top