[Fxruby-users] Disconnecting Foxtails Elements
Status: Inactive
Brought to you by:
lyle
From: Will M. <wi...@co...> - 2003-12-10 00:18:28
|
Hi, This question is mostly for Joel VanderWerf, but if any one else has any ideas please jump in. The question is how to cancel the observation of a variable in a Foxtails element? As you can see in the included code below, (Yes its the same code I included in my other message today.) I am adding several FTTextFields to watch some variables in another object. The object I wish to observe changes from time to time so these fields need to be added dynamically. So the specific question is: when I stop observing one object and start observing a new object what do I need to do to clean up the observations on the old object? In the Observable library that you wrote there are cancel_when_* methods that do this job, what are the equivilent methods for Foxtails? Thanks, --Will ==================== begin include ================= #!/usr/bin/env ruby require 'fox' require 'fox/responder' require 'observable' require 'foxtails' include Fox include Observable include FoxTails class ObjectInspector include Responder extend Observable def initialize(app, proj) @targetObject = nil createWindow(app, proj) end def createWindow(app, proj) @app = app @project = proj @inspectordlg = FXDialogBox.new(app, "Inspector", DECOR_BORDER|DECOR_RESIZE|DECOR_TITLE, 0, 0, 150, 300) @matrix = FXMatrix.new(@inspectordlg, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X) end def clear() @matrix.hide end def set(newobj) @targetObject = newobj @matrix = FXMatrix.new(@propertyFrame, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X) # First row FXLabel.new(@matrix, "Property", nil, LAYOUT_FILL_COLUMN) FXLabel.new(@matrix, "Value", nil, LAYOUT_FILL_COLUMN) # First row FXLabel.new(@matrix, "Type", nil, LAYOUT_FILL_COLUMN) FXLabel.new(@matrix, @targetObject.name, nil, LAYOUT_FILL_COLUMN) FXLabel.new(@matrix, "Left", nil, LAYOUT_FILL_COLUMN) FTTextField.new(@matrix, 17, @targetObject, :left, FRAME_SUNKEN|LAYOUT_FILL_COLUMN) FXLabel.new(@matrix, "Right", nil, LAYOUT_FILL_COLUMN) FTTextField.new(@matrix, 17, @targetObject, :right, FRAME_SUNKEN|LAYOUT_FILL_COLUMN) FXLabel.new(@matrix, "Top", nil, LAYOUT_FILL_COLUMN) FTTextField.new(@matrix, 17, @targetObject, :top, FRAME_SUNKEN|LAYOUT_FILL_COLUMN) FXLabel.new(@matrix, "Bottom", nil, LAYOUT_FILL_COLUMN) FTTextField.new(@matrix, 17, @targetObject, :bottom, FRAME_SUNKEN|LAYOUT_FILL_COLUMN) @inspectordlg.create @inspectordlg.show # @inspectordlg.update # @inspectordlg.repaint @inspectordlg.resize(@inspectordlg.width + 1, @inspectordlg.height) @inspectordlg.resize(@inspectordlg.width - 1, @inspectordlg.height) end # Close the Inspector Windows def close @inspectordlg.hide end # Create and show the main window def create # Create the windows @inspectordlg.create @inspectordlg.show(PLACEMENT_DEFAULT) end end ===================== end include ================== |