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

creating a menu

New Here ,
Aug 16, 2010 Aug 16, 2010

HI all

How is it possible to implement in javascript a menu you can see in the picture? on the right you have a input box and right of the input box a little button. when you click on this button you become a list. clicking on a item it adds a text to the input box.

Thanks a lot for your help

indesign_meu.png

TOPICS
Scripting
2.9K
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

correct answers 1 Correct answer

Advisor , Aug 20, 2010 Aug 20, 2010

You must use ScriptUI for creating dialog to achieve this. Standard InDesign dialog components that you are using doesn't allow 'onChange' events.

--

tomaxxi

http://indisnip.wordpress.com/

Translate
Community Expert ,
Aug 17, 2010 Aug 17, 2010

You can do that using ScriptUI, but if you've not used that before then you'll not find that easy.

Peter

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
New Here ,
Aug 18, 2010 Aug 18, 2010

Hi Peter

And how can I do that? Do you have an example or do you know where can I find more information?

Thanks a lot

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 ,
Aug 18, 2010 Aug 18, 2010

The only documentation available (so far) is the PDF file you access via the ESTK's Help menu. The file is called "JavaScript Tools Guide CSx.pdf".

Peter

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
LEGEND ,
Aug 18, 2010 Aug 18, 2010

pkahrel wrote:

The only documentation available (so far)...

Peter,

Is that a hint?

Harbs

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 ,
Aug 18, 2010 Aug 18, 2010

> Is that a hint?

It is!

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
LEGEND ,
Aug 18, 2010 Aug 18, 2010

Cool! Looking forward to seeing the results!

(I'll be happy to read through it if you'd like...)

Harbs

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
Advisor ,
Aug 18, 2010 Aug 18, 2010

Yeah, that sounds great!

Adobe's documentation about ScriptUI is sometimes not enough.

--

tomaxxi

http://indisnip.wordpress.com/

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
New Here ,
Aug 19, 2010 Aug 19, 2010

that's right. couldn't find anything in the documentation which are mentioned above.

Do I need to create a edittext and beside the textbox a imageiconbutton or does adobe provide a class which provide a edittext with button on list?

maybe does someone has an example?

thanks

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
Advisor ,
Aug 19, 2010 Aug 19, 2010

Hey!

I wrote something (not longer than 15 minutes), maybe it will help you.

var myList = Array("  ----Select Item----  ","Item 1","Item 2","Item 3","sep","Item 4","Item 5","Item 6","sep","Item 7","Item 8","Item 9","Item 10","Item 11");
var myItems = Array("","\\i1","\\i2","\\i3","","\\i4","\\i5","\\i6","","/i7","/i8","\\i9","//es{0,","/\\mix");

var win = new Window('dialog','Custom Insert Menu');
win.orientation = 'row';
win.spacing = 0;
with(win){
     editText = add('edittext');
     editText.preferredSize = [250,25];
};
var myDrop = win.add('dropdownlist');
for(var i = 0; i < myList.length; i++){
    if(myList == "sep")
    myDrop.add('separator');
    else
    myDrop.add('item',myList);
}
myDrop.selection = 0;
myDrop.preferredSize = [5,25];

myDrop.onChange = function(){editText.text += myItems[myDrop.selection.index];myDrop.selection = 0;}

win.center();
win.show();

--

tomaxxi

http://indisnip.wordpress.com/

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
New Here ,
Aug 20, 2010 Aug 20, 2010

Hi tomaxxi

It's not exactly the same but it helps me a lot. Now I have a last questions.

When I create a Dialog

    var dialog = app.dialogs.add({name:"Reformat Index"});

and add a dropdown

    with(dialog.dialogColumns.add()) {
        var spacesDrop = dropdowns.add({stringList:spaces, selectedIndex:0});
    };

I cannot use the onChange event on the dropdown like you did

//not possible

spacesDrop.onChange = function() { delimiterField.text += codes[spacesDrop.selection.index]; spacesDrop.selection = 0; };

Instead of using a dialog, a window works like in your example.

Is that normal that events doesn't work on dialogs?

thanks a lot

pasithee

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
Advisor ,
Aug 20, 2010 Aug 20, 2010

You must use ScriptUI for creating dialog to achieve this. Standard InDesign dialog components that you are using doesn't allow 'onChange' events.

--

tomaxxi

http://indisnip.wordpress.com/

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
New Here ,
Aug 20, 2010 Aug 20, 2010

now everything is clear.

thanks a lot

pasithee

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
Advisor ,
Aug 20, 2010 Aug 20, 2010

I was wondering could you maybe post screenshot of function that I maid if you are using MacOSX. I'm curious how it looks like.

Thanks.

--

tomaxxi

http://indisnip.wordpress.com/

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
Engaged ,
Aug 20, 2010 Aug 20, 2010

Hi tomaxxi,

Here are screenshot of your script from MAC.

Picture 2.png

Picture 4.png

Shonky

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
Advisor ,
Aug 20, 2010 Aug 20, 2010

Thanks Shonkyin!

It looks just fine... Maybe just to adjust dropdown width to 15:

myDrop.preferredSize = [15,25];

On Windows dropdown is little bit wider. It looks like this:

custom_dropdown.jpg

I like this feature, maybe just add icons to drop down, and you have nice little helper menu

--

tomaxxi

http://indisnip.wordpress.com/

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
Advisor ,
Aug 23, 2010 Aug 23, 2010
LATEST

Hey!

If you are interested, I made some changes to the script with some explanations. You can find it here: http://bit.ly/czEaHA

--

tomaxxi

http://indisnip.wordpress.com/

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
Advisor ,
Aug 18, 2010 Aug 18, 2010

You can also find great samples in '\Adobe\Adobe Utilities - CS5\ExtendScript Toolkit CS5\SDK\Samples\javascript\'

--

tomaxxi

http://indisnip.wordpress.com/

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