Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

ScriptUI Panel .onClick help

Participant ,
Mar 28, 2014 Mar 28, 2014

Here is my code.

function myScript(thisObj) {
    function myScript_buildUI(thisObj) {
        var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Align 3D Layers", undefined, {resizeable:true});
       
        res = "group{orientation:'row',\
        groupOne: Group{orientation: 'row',\
        myButton: Button{text:'Apply'},\
                myDropDownList: DropDownList{properties:{items:['DD item1', 'DD item 2', 'DD item 3']}},\
        },\
        groupTwo: Group{orientation:'column',\
        myStaticText: StaticText{text:'My static text'},\
        myEditText: EditText{text:'my edittext'},\
        myIconButton: IconButton{text:'IconButton', Image:'`/Desktop/skullIcon.jpg'},\
        myImage: Image{text:'Image', Image:'`/Desktop/skullIcon.jpg'},\
        },\
        }";
       
        myPanel.grp = myPanel.add(res); 
       
        return myPanel;
    }
    var myScriptPal = myScript_buildUI(thisObj);

    myPanel.group.groupOne.myButton.onClick = function()
    {
        alert("It lives!")
        }

   
    if((myScriptPal != null) && (myScriptPal instanceof Window)) {
        myScriptPal.center();
        myScriptPal.show();
    }
}

myScript(this);

I'm trying to learn how to make a button carry out a function but I get an error. I'm pretty fuzzy on the ScriptUI syntax. What am I doing wrong?

TOPICS
Scripting
770
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 28, 2014 Mar 28, 2014

Try changing this:

myPanel.group.groupOne.myButton.onClick = function()

to this:

myScriptPal.grp.groupOne.myButton.onClick = function()

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 28, 2014 Mar 28, 2014
LATEST

You Sir are awesome. Thanks very much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines