I am new to (FX)ruby and am wrestling with the following question. In my application I have a three frame split by two splitters. One frame on the left side with a treelist and two frames above each other on the right side. The editable content of the right top frame depends on the item clicked in the treelist. The editable content of the right bottom frame depends on data enter in the right top frame. I maganged to program all this for the first click on a tree-item. My question is how do I reset righttopframe and rightbottomframe after handling treeitem(1) and before click on the next item. I tried righttopframe.destroy but that that does not seems to do the work. Since after a destroy "if righttopframe" still gives value true. in pseudo code my program is now on click tree item { build right topframe righttopframe.create righttopframe.show } on click righttopframe_button { build right bottomframe rigthbottomframe.create rightbottomframe.show} on click rightbottomframe-button { edit database} Thank you for any suggestions. Ernst -------------- next part -------------- A non-text attachment was scrubbed... Name: ernst.vcf Type: text/x-vcard Size: 264 bytes Desc: not available Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20071212/30a93ac4/attachment.vcf
On 12/12/07, Ernst J. Tanaka <ernst at tanakasite.com> wrote:> My question is how do I reset righttopframe and rightbottomframe after > handling treeitem(1) and before click on the next item.I think the important question is what you mean by "reset". Acually, a question very similar to yours came up the other day on the mailing list; here''s a link to the first post in that thread: http://rubyforge.org/pipermail/fxruby-users/2007-December/001371.html My advice in that thread was to just update the values associated with the widgets (if possible) instead of removing and re-creating them. For example, suppose the top-right frame contains three widgets. You can update their values by simply setting new values for their text, e.g. on click treeItem button.text = "New button text" label.text = "New label text" textfield.text = "New text field text" end You can do something similar to update the contents of the bottom-right frame at the appropriate time. If, however, you really do need to get rid of the widgets in the top-right frame, use removeChildren() and not destroy(), e.g. parent = righttopframe.parent parent.removeChild(righttopframe) Note that this won''t set righttopframe to nil, so you need to be careful not to use that value anymore until you assign some new value to it. Hope this helps, Lyle
On Dec 12, 2007 10:12 PM, Ernst J. Tanaka <ernst at tanakasite.com> wrote: [...]> > I tried righttopframe.destroy but that that does not seems to do the > work. Since after a destroy "if righttopframe" still gives value true. > >Sure! The object residing in the variable righttopframe is still there. By calling destroy you tell FOX to release WindowManager-resources etc. but not to destroy the object at hand. This is not possible in Ruby, it is done by the garbage collector automatically. As Lyle pointed out earlier, righttopframe.parent.RemoveChild(righttopframe) is the correct way to do what you attempted to do, even if there are better ways to update content in a UI. After that, if you explicitly set the variable righttopframe = nil then your if statement above also works. hth, -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20071213/332ac3bd/attachment.html