Automatic Layout Manager Fail

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
vidjuheffex
Posts: 18
Joined: May 6th, 2012, 2:11 pm

I have the following code:

Code: Select all

var musket = function() {
    var w;
    var title;
       
    return {

        init: function(thisObj){
            w = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Musket", undefined, {resizeable:true, orientation:'column', alignChildren:['left','top']});
            w.title = w.add("statictext", [10,10,30,30], 'Musket 2.0');
//~             projDDlist = w.add("dropdownlist",undefined,["option","option","option"]);
//~             projDDlist.preferredSize = [125,20];
//~             shotDDlist = w.add("dropdownlist",undefined,["option","option","option"], {preferredSize:[-1,-1]});
            return w;
        }
    }
}();

musket.init(this);
The only way w.title shows up is if I include the [10,10,30,30] portion of the arguments. If I write "undefined" (without quotes), it does not get written. I was under the impression that if I did not include that, the automatic layout would kick in and an acceptable size would be determined. What am I missing, you can see in the commented out section some other stuff I have tried. Nothing works unless something besides undefined is given. Does automatic layout only work with Resource Strings (which are indefensibly awful. Where they get their popularity and rampant use is beyond me.)

As a side note I love how the entire scriptUI tools guide chapters use code based examples then they introduce Res Strings, and every following example, as it moves to advanced topics, is only in Res Strings ignoring the entire chapter that preceded it which was code-based. ARGH!
vidjuheffex
Posts: 18
Joined: May 6th, 2012, 2:11 pm

Alright I figured it out:

show() is what automatically invokes the layout manager. However show() does not work when creating dockable ScriptUI panels. You need to invoke the layout by calling the layout function of its layout property. In other words:

w.layout.layout();

return w;


this way the code is name-spaced/dockable/and not in stupid res-strings format.
Post Reply