[Fxruby-users] New tab item not visible via block
Status: Inactive
Brought to you by:
lyle
From: Duane J. <dua...@gm...> - 2004-06-17 17:42:51
|
I have an FXTabBook object to which I'm adding pairs of FXTabItem and FXFrame. This works perfectly until I try to add a pair from within a menu item message block. In other words, I want to be able to click "New" in the file menu and have a new tab item with its contents appear. The trouble is that although the code is being executed, the FXTabItem is not appearing. Here is the code (simplest case): <pre> require 'fox' require 'fox/colors' include Fox class PlayTextMainWindow < FXMainWindow def initialize(app) # Call the base class initialize() first super(app, "PlayText", nil, nil, DECOR_ALL, 0, 0, 800, 600) # Menu bar, along the top menubar = FXMenubar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X) # Separator FXHorizontalSeparator.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SEPARATOR_GROOVE) $editorTabs = FXTabBook.new( self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP) # NOTE: This call to addEditor WORKS addEditor( "New" ) # File menu filemenu = FXMenuPane.new(self) FXMenuCommand.new(filemenu, "&New\tCtl-N\tNew Text Window.").connect(SEL_COMMAND) do # NOTE: This call to addEditor is made, but a new tab DOES NOT appear! addEditor( "test", "", true ) end FXMenuCommand.new(filemenu, "&Quit\tCtl-Q\tQuit the application.", nil, getApp(), FXApp::ID_QUIT) FXMenuTitle.new(menubar, "&File", nil, filemenu) end def addEditor( title, filename="", focus=true ) ti = FXTabItem.new( $editorTabs, title, nil, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_LEFT ) p title # Play text window frame = FXHorizontalFrame.new( $editorTabs, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_LINE ) editor = FXText.new( frame, nil, 0, TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y) if( focus ) $currentTextWindow = editor $currentTextWindow.setFocus() end end def create super show(PLACEMENT_SCREEN) end end if __FILE__ == $0 application = FXApp.new("PlayText", "(C)2004 Duane Johnson") stw = PlayTextMainWindow.new( application ) stw.enable # NOTE: This call to addEditor WORKS stw.addEditor( "duane", "", true ) application.create application.run end </pre> I'd love to have some ideas on where I can modify this. Thanks! Duane Johnson |