Copy link to clipboard
Copied
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
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/
Copy link to clipboard
Copied
You can do that using ScriptUI, but if you've not used that before then you'll not find that easy.
Peter
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
pkahrel wrote:
The only documentation available (so far)...
Peter,
Is that a hint?
Harbs
Copy link to clipboard
Copied
> Is that a hint?
It is!
Copy link to clipboard
Copied
Cool! Looking forward to seeing the results!
(I'll be happy to read through it if you'd like...)
Harbs
Copy link to clipboard
Copied
Yeah, that sounds great!
Adobe's documentation about ScriptUI is sometimes not enough.
--
tomaxxi
http://indisnip.wordpress.com/
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
now everything is clear.
thanks a lot
pasithee
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
Hi tomaxxi,
Here are screenshot of your script from MAC.
Shonky
Copy link to clipboard
Copied
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:
I like this feature, maybe just add icons to drop down, and you have nice little helper menu
--
tomaxxi
http://indisnip.wordpress.com/
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
You can also find great samples in '\Adobe\Adobe Utilities - CS5\ExtendScript Toolkit CS5\SDK\Samples\javascript\'
--
tomaxxi
http://indisnip.wordpress.com/
Find more inspiration, events, and resources on the new Adobe Community
Explore Now