Why is the width of an FXSplitter equal to 1 before the FXSplitter#create method is called? My splitter is configured to have LAYOUT_FILL_X, so wouldn''t its width be determined before its children were created? It''s not really a big deal, but I was configuring the split based on a preferences file during initialize, and couldn''t make it work properly. Doing it in #create is an acceptable workaround. This isn''t a problem with FX4Splitter. The splitting is implemented differently (and the split values have different meaning). Somehow, both hSplit and vSplit are available before create. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Joel VanderWerf wrote:> Why is the width of an FXSplitter equal to 1 before the > FXSplitter#create method is called? > > My splitter is configured to have LAYOUT_FILL_X, so wouldn''t its width > be determined before its children were created? > > It''s not really a big deal, but I was configuring the split based on a > preferences file during initialize, and couldn''t make it work properly. > Doing it in #create is an acceptable workaround. > > This isn''t a problem with FX4Splitter. The splitting is implemented > differently (and the split values have different meaning). Somehow, both > hSplit and vSplit are available before create.I''m sorry, that bit about FX4Splitter is nonsense. FX4Splitter has width==1 and height==1 before create, as well. What I should have said is that FX4Splitter''s splitting mechanism (proportional rather than based on width) makes this irrelevant to my code, which really just wants to set the proportions, and not the widths of the children. I guess FXSplitter (as opp. FX4Splitter) can''t work that way because it might have >2 children. So I''ll stick with configuring it in #create. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Joel VanderWerf wrote: ...> So I''ll stick with configuring it in #create.Btw, ruby closures are a very clean way to do this. def on_create(&block) @create_actions ||= [] @create_actions << block end def do_create_actions @create_actions and @create_actions.each do |action| action.call end end def initialize(*) splitter = ... on_create do # <-- this is all I had to change in initialize # configure the splitter based on its width and the preferences # for split proportion end end def create super do_create_actions show end Ok, that''s enough noise for a while. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
On Apr 26, 2007, at 6:22 PM, Joel VanderWerf wrote:> Joel VanderWerf wrote: > ... >> So I''ll stick with configuring it in #create. > > Btw, ruby closures are a very clean way to do this.<snip> This is a nice hack; I like that it keeps the splitter-specific configuration close to the spot where you actually construct the splitter. Thanks for sharing it!