Skip to main content
Roy Marshall
Known Participant
July 22, 2009
Answered

[JS][CS3] Selection Menu with images

  • July 22, 2009
  • 2 replies
  • 1578 views

I have no idea it this is possible, but I have written this code at the start of a script to select a function within the script:

myDialog = app.dialogs.add({name:"Catalogue Selector"});

with(myDialog)

     {

        with(dialogColumns.add())

          {

          with(dialogRows.add())

               {

               staticTexts.add({staticLabel:"Select the required catalogue:"});

               myOptionButtons = radiobuttonGroups.add();

               with(myOptionButtons)

                    {

                    radiobuttonControls.add({staticLabel:"VW"});

                    radiobuttonControls.add({staticLabel:"Peugeot"});

                    radiobuttonControls.add({staticLabel:"MG Rover"});

                    radiobuttonControls.add({staticLabel:"BMW Special"});

                    radiobuttonControls.add({staticLabel:"Nissan HTML"});

                    radiobuttonControls.add({staticLabel:"Nissan XLS"});

                    radiobuttonControls.add({staticLabel:"BMW (GB)"});

                    radiobuttonControls.add({staticLabel:"SEAT"});

                    radiobuttonControls.add({staticLabel:"Citroen"});

                    radiobuttonControls.add({staticLabel:"Vauxhall"});

                    radiobuttonControls.add({staticLabel:"SAAB 1st Column"});

                    radiobuttonControls.add({staticLabel:"SAAB 2nd Column"});

                    radiobuttonControls.add({staticLabel:"Audi"});

                    radiobuttonControls.add({staticLabel:"Fiat"});

                    radiobuttonControls.add({staticLabel:"Ford"});

                    radiobuttonControls.add({staticLabel:"Ford LCV"});

                    radiobuttonControls.add({staticLabel:"Honda"});

                    radiobuttonControls.add({staticLabel:"Vauxhall FUNNY SIZE"});

                    radiobuttonControls.add({staticLabel:"Hyundai"});

                    }

               }

          }

     }

myResult = myDialog.show();

and what I want to be able to do is add an image to each option.
Is this possible?

I am looking to work with CS3 only at the moment.

Cheers

Roy

This topic has been closed for replies.
Correct answer Adobe-InDesign_CS4

Thanks for that.  I got there in the end.

One last thing (for now anyway) I have this bit of code:

//Adding Buttons

myButton1 = myPanel.add('button', [380,13,75,25], 'Choose',{name:'button1'});

myButton2 = myPanel.add('button', [380,53,75,25], 'Choose',{name:'button2'});

myButton3 = myPanel.add('button', [380,93,75,25], 'Choose',{name:'button3'});

myCancel = myDialog.add('button', [500,120,100,25], 'Cancel',{name:'cancel'});

myImage = myDialog.add('image',[487,16,588,100],'/Macintosh HD/Applications/Adobe InDesign CS3/Scripts/Scripts Panel/Images/xxx.png');

myCopyright = myDialog.add('statictext',[15,153,400,172],'©xxxxxxx Ltd 2009');

myResult = myDialog.show();

if (myResult == 'myButton1')

     {

     alert ("myButton1 was pressed");

     }

if (myResult ==2)

     {

     alert ("Cancel was pressed");

     }

I need to run a function depending of the myResult, but the above myResult bit isn't working at all.  Cancel does work, but not:
if (myResult == 'myButton1')
Can someone please give me the correct syntax for this?
Many Thanks
Roy


Dear Roy Marshall

  Please use the below code:

var myDialog= new Window(''dialog','Sample');

//Adding Buttons

myButton1 = myPanel.add('button', [380,13,75,25], 'Choose',{name:'button1'});

myButton2 = myPanel.add('button', [380,53,75,25], 'Choose',{name:'button2'});

myButton3 = myPanel.add('button', [380,93,75,25], 'Choose',{name:'button3'});

myCancel = myDialog.add('button', [500,120,100,25], 'Cancel',{name:'cancel'});

myImage = myDialog.add('image',[487,16,588,100],'/Macintosh HD/Applications/Adobe InDesign CS3/Scripts/Scripts Panel/Images/xxx.png');

myCopyright = myDialog.add('statictext',[15,153,400,172],'©xxxxxxx Ltd 2009');

myButton1.onClick= function()

{

    alert("this is First");

}

myButton2.onClick= function()

{

    alert("this is Second Button");

}

myButton3.onClick= function()

{

    alert("this is Third Button");

}

myCancel.onClick= function()

{

    alert("Close the Menu");

     myDialog.close();

}

myDialog.show();

Use this Code!!

Regards

T.R.Harihara SudhaN

2 replies

Kasyan Servetsky
Brainiac
July 23, 2009

You can do this using ScriptUI (not InDesign's dialog). ListItem has image property:

An image object for an icon to display in the item.

When specified, the image appropriate to the selections state is drawn to the  left of the text label.

Kasyan

Roy Marshall
Known Participant
July 24, 2009

Thanks for the reply Kasyan

I am building the dialog, (I am not sure I am using ScriptUI) as below:

var myDialog = new Window('dialog', 'Roys Box');

myDialog.frameLocation = [100,100];

myDialog.size = [500, 120];

myPanel= myDialog.add('panel', [10,10,480,100], 'Roys Panel');

myTopText = myPanel.add('statictext', [17,15,100,55],'Top Text');

myBottom = myPanel.add('statictext', [17,50,100,85],'Bottom Text');

myLine= myDialog.add('panel', [18,55,370,0], 'Roys Panel');

myOKButton = myPanel.add('button', [390,10,75,10], 'Done',{name:'ok'});

myCancelButton = myPanel.add('button', [390,40,75,25], 'Cancel',{name:'cancel'});

myImage = myDialog.add('image',undefined,"image.png");

myResult = myDialog.show();

but the myImage line errors saying 'File or Folder does not exist'.  The guide does not state how to use this method including the file path.

Any ideas on how to make this work?

Cheers

Roy

Roy Marshall
Known Participant
July 24, 2009

After playing with all ways of code, I got it!!!:

myImage = myDialog.add('image',[490,30,588,95],'~/image.png');

Phwew!

Roy

Roy Marshall
Known Participant
July 22, 2009

sorry, please ignore the "&n bsp;"

Not sure how that happened.

Roy