Re: [Fxruby-users] Deleting widgets
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <ly...@kn...> - 2003-10-12 23:12:39
|
Phil Sharp wrote: > After adding an FXLabel to a FXHorizontalFrame, I destroyed the label, > then attempted to add a new one. The new one was created ok except that > it's placement was offset as if the one that I just deleted was still > there. > > Is there another step that must be taken to cause the frame to "forget" > about the just deleted widget? The correct way to cause a parent frame to forget about one of its child widgets is to use the removeChild() method: aHorizontalFrame.removeChild(aLabel) Calling destroy() on the label widget destroys the server-side representation (i.e. the X window or Windows HWND associated with the label) but it doesn't destroy the client-side representation, namely the C++ or Ruby object associated with the label. Calling removeChild() is the proper approach because it takes care of all of the bookkeeping associated with "forgetting" a child widget. First, it removes the widget from the parent's list of child widgets and nulls out any references to the child widget. Next, it calls recalc() on the parent (as suggested by Henon) to mark the parent's layout as dirty. Finally, it calls destroy() on the widget, to destroy the server-side resource. |