From: jjthrash@... Date: 2001-03-14T11:11:01+09:00 Subject: [ruby-talk:12593] FXRuby question Hello, I'm having trouble getting the following to work. For some reason, the FXTextField doesn't want to take input. Can anyone help? Even better, can anyone point me to some documentation which describes how different Widgets are used? The FOX documentation seems very high-level and not useful to a quick-hack programmer, and the examples aren't inclusive enough. Thanks, Jimmy # This method and the Responder module were taken from the # example code that came with FXRuby. def enum(start, count) (start...(start+count)).to_a end module Lazy def lazyInitialize(symbol) if ( instance_eval("@" + symbol.to_s).nil? ) yield end return instance_eval("@" + symbol.to_s) end def globalLazyInitialize(symbol) if ( eval("$" + symbol.to_s).nil? ) yield end return eval("$" + symbol.to_s) end end module Responder # Initialize the array of associations for the class as empty @@assocs = [] # Look up array index of this message map entry def assocIndex(lo, hi) currIndex = -1 @@assocs.each_index { |i| if @@assocs[i][0] == lo && @@assocs[i][1] == hi currIndex = i end } return currIndex end # Add new or replace existing map entry def addMapEntry(lo, hi, func) currIndex = assocIndex(lo, hi) if currIndex < 0 @@assocs.push([lo, hi, func]) else @@assocs[currIndex] = [lo, hi, func] end end # Define range of function types def FXMAPTYPES(typelo, typehi, func) addMapEntry(MKUINT(MINKEY, typelo), MKUINT(MAXKEY, typehi), func) end # Define one function type def FXMAPTYPE(type, func) addMapEntry(MKUINT(MINKEY, type), MKUINT(MAXKEY, type), func) end # Define range of functions def FXMAPFUNCS(type, keylo, keyhi, func) addMapEntry(MKUINT(keylo, type), MKUINT(keyhi, type), func) end # Define one function def FXMAPFUNC(type, id, func) addMapEntry(MKUINT(id, type), MKUINT(id, type), func) end end class FoxVortareto require 'fox' include Lazy include Responder include Fox def initialize initGUI showGUI end def initGUI mainWindow #FXMAPFUNC(SEL_COMMAND, FXTextField::ID_INSERT_CHAR, "onUpdateText") end def showGUI mainWindow.show end def run mainApp.create mainApp.run end def mainWindow lazyInitialize(:mainWindow) { @mainWindow = FXMainWindow.new(mainApp, "Vortareto", nil, nil, DECOR_ALL, 0, 0, 300, 300) mainPanel } end def mainApp lazyInitialize(:mainApp) { @mainApp = FXApp.new("Vortareto", "SMOOS") @mainApp.init([]) } end def mainPanel lazyInitialize(:mainPanel) { @mainPanel = FXVerticalFrame.new(mainWindow, LAYOUT_FILL_X | LAYOUT_FILL_Y) lookupPanel resultsPanel } end def lookupPanel lazyInitialize(:lookupPanel) { @lookupPanel = FXHorizontalFrame.new(mainPanel, LAYOUT_FILL_X) FXLabel.new(@lookupPanel, "Trovu:", nil, 0) lookupTextField } end def lookupTextField lazyInitialize(:lookupTextField) { @lookupTextField = FXTextField.new(lookupPanel, 40, nil, 0) @lookupTextField.setText("") } end def resultsPanel lazyInitialize(:resultsPanel) { @resultsPanel = FXVerticalFrame.new(mainPanel, LAYOUT_FILL_X | LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK) resultsListView } end def resultsListView lazyInitialize(:resultsListView) { @resultsListView = FXList.new(resultsPanel, 20, nil, 0, LAYOUT_FILL_X | LAYOUT_FILL_Y | LIST_BROWSESELECT) } end # # Message handlers # def onUpdateText(sender, sel, ptr) print "hi\n" end end window = FoxVortareto.new window.showGUI window.run # vim:noet: -- jjthrash SPAM pobox SPAM com