Copy link to clipboard
Copied
I would like to make custom palettes for Illustrator which have the ability to get out of the way, similar to native palettes. On Windows, my minimized = true; command works, and the palette shrinks into a tiny bar, which I like. However, same command on Mac does not do the trick.
#target illustrator
#targetengine main
function myPanel(){
var arr = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
function paletteWindow(){
var w = new Window('palette', 'My Panel', undefined, {resizeable: true});
var g1 = w.add('group');
var t = g1.add('treeview', undefined, []); t.size = [200, 450];
for(var i=0; i<arr.length; i++){
var item = arr;
var n = t.add('node', item);
}
t.onDoubleClick = function(){
if(t.selection != null && t.selection.text != ''){
alert(t.selection.text);
}
};
var btn_min = w.add('button', undefined, 'Minimize');
btn_min.onClick = function(){
w.minimized = true;
w.update();
}
w.onResizing = w.onResize = function () {this.layout.resize ();}
w.onShow = function(){
w.minimumSize.width = 220;
w.minimumSize.height = 100;
t.items[1].expanded = true;
}
this.show = function(){w.show();}
}
var thisPaletteWindow = new paletteWindow(); // have to call it like this, or it disappears.
thisPaletteWindow.show();
}
myPanel();
Aha- this is something a little bit better.
Also, I guess there's no reason to pass in an object if it can be kept outside the palette functions. Not sure why I even thought that was the way to go? ![]()
...#target illustrator
#targetengine main
function myPanel(){
var arr = [];
for(var i=33; i<123; i++){
arr.push(String.fromCharCode(i)+" ------------ text line");
}
function tinyWindow(storeObj){
var w = new Window('palette', 'MiniPanel', undefined, {borderless: false,
Copy link to clipboard
Copied
Yeah fun, fun, (sorry for my glossing over all the unneeded confusion due to Adobe's ineptitude.) Sigh, you could check the app version and build the UI accordingly for each. ScriptUI is headed to be as good as dead across all products from what I have been reading. Just like CC, they are moving in a different direction and burning bridges all the way there.
Copy link to clipboard
Copied
Oh no the end is near? Please elaborate! Is this having to do with extensions and stuff?
Copy link to clipboard
Copied
My fist play with this proved to frustrate me a bit.
I found when you moved it quickly and got the cursor off the wind things got messy.
but I will persist and see if it can be made more stable.
Copy link to clipboard
Copied
added a bar to drag from and an extra event handler.
Found this stops the issue with fast mouse movement causing issues when the upHandler cannot fire due to cursor leaving the window.
Only tested in CC2014 - Note the #target illustrator-18 #target illustrator
//#target illustrator
#target illustrator-18
#targetengine main
function demo () {
var win = new Window ("palette", undefined, undefined, {borderless:true});
// ***************************
// CC - add a panel the size of the window, then add all controls to the panel as usual
// then when the script runs, click and drag anywhere within the Panel
//added a bar to drag from to emulate illustrator panels
var bar = win.add('group');
bar.graphics.backgroundColor = win.graphics.newBrush(win.graphics.BrushType.SOLID_COLOR,[0.17,0.17,0.17], 1);
bar.size = [200,13];
bar.margins = 0;
var p = win.add('panel');
p.alignment = ['fill', 'fill'];
win.size = [200,150];
win.margins = 1;
win.spacing = 1;
// ***************************
// CS6 - didn't work with the panel above, controls must be added to the Window itself
// CS5 - works OK with or without the Panel
// Thanks Adobe !!!
var btnOk = p.add('button', undefined, 'OK');
var btnCancel = p.add('button', undefined, 'Close');
btnCancel.onClick = function () {win.close()}
makeWinDraggable (win,bar); // click and drag on any empty space in the Window (or Panel) to move it around
win.show();
}
demo();
function makeWinDraggable (w,bar) {
/* //*********************************************
Pass a window of any kind to be able to click and drag the window around
CC - didn't work, had to add a panel the size of the window, then add all controls to the panel
CS6 - didn't work with the panel, add controls to the Window
CS5 - worked beautifully with or without the panel, all testing done in Windows
Carlos Canto // 04/12/15
*/ //*********************************************
var xClient, yClient; // mouse position from left/top window (client is the Panel if added)
w.drag = false;
bar.addEventListener('mousemove', moveHandler); //calls function when the mouse moves inside the window
bar.addEventListener('mousedown', downHandler); // (eventName, handler, capturePhase);
bar.addEventListener('mouseup', upHandler); // (eventName, handler, capturePhase);
bar.addEventListener('mouseout', upHandler); // fix for fast mouse movement that leaves cursor outside window without triggering upHandler
function moveHandler(e) {
if (w.drag) {
w.location = [e.screenX-xClient, e.screenY-yClient]; // screenX/Y, mouse position from Monitor left/top
}
}
function downHandler(e) {
w.drag = true;
xClient = e.clientX;
yClient = e.clientY;
}
function upHandler(e) {
w.drag = false;
}
}
Copy link to clipboard
Copied
the bar works fine in CS5, thanks for adding the mouseout event
Copy link to clipboard
Copied
Disappointed or Missed me?
the latter of course ![]()
Copy link to clipboard
Copied
sorry my bad english![]()
It's possible to convert that in a Script Panel?
example, double click in "A" and run process or other script? thanks
Copy link to clipboard
Copied
Yes, I've made a previous example, but it is still in progress. I'll put it up on GitHub when it is complete.
Copy link to clipboard
Copied
Okay, here it is. The purpose is to have a working model for other developers to pick out the "good parts", or just to navigate the logic and make a whole new custom one.
So what we have is:
The idea is to be able to distribute this panel to workstations, and control the configuration of each one with a single XML file.
There's also the incomplete "Open in ESTK" function, which could probably be made workable by someone smart.
imagecollection‌ can probably polish this mess into something good ![]()
Adobe-Illustrator/ScriptPanel.jsx at master · Silly-V/Adobe-Illustrator · GitHub
Copy link to clipboard
Copied
AWESOME!!! the best script!!
Thanks very much, you are outstanding, works 100%
Copy link to clipboard
Copied
Not had heaps of time to play with this yet, but initial impression is WOW.
I like the layout and it all seems very functional.
A lot of work has gone into this!!!
I have been working on the same thing as some will know, but I just spent a month friking about with Bridgetalk.
Finally got that working so I am happy and now you pull this.
I am impressed and will be using this as of now!
the only improvements I can think of right now would be a Sub Folder option in the config.
and maybe the option to Type or Paste in the choose folder dialog.
and a way to re-order the folders in tree view.
But these are minor fixes.
Again
Great work!![]()
Copy link to clipboard
Copied
The only major thing is not with your script but ScripUI.
is there anyone who know how to make a "borderless = true" palette, and keep the ability to re-position with the mouse?
Copy link to clipboard
Copied
Thank you, and it is now up to you to take it to the next level ![]()
Oh , and I briefly took a look at trying to do borderless, but no luck there. Otherwise, it's amazing that it still works from CS5 to CC+, even through all the ScriptUI changes.
Copy link to clipboard
Copied
yeah, I've noticed that a lot of the Mouse event listners do not work as expected in cc+
Copy link to clipboard
Copied
Also, just to remind everyone, big grain of salt when investing reliance on this method: scripts are launched via bridgetalk, so there's no debugging- you get silent failure. As in the instructions, $.fileName in target scripts is not going to work, so there's a hard-coded variable for this kind of thing to help out. ScriptPanel_MyLocation. All in all, please use caution and know that this is a community-based work-in-progress, so it's far from the stability which may be offered by a plugin, for instance. I say this because just today, I had an experience where the scripts didn't execute for no reason at all, until I restarted my AI.
Copy link to clipboard
Copied
Silly-V‌, Question on the Embedded Images.
more info, did you do the embedding?
the script I have found to do this is not working, guessing I am not using it correctly or feeding it an incorrect file formatting, or something.
Thanks in advance![]()
Copy link to clipboard
Copied
Scrap that, I got it working.
1 more dumb error on my behalf.
Copy link to clipboard
Copied
There is some nice little gems in this code,
thanks again.
there is always so much to learn...
Copy link to clipboard
Copied
It's like a box of crayons!
I'm excited to see what you're going to come up with!
Copy link to clipboard
Copied
ha, Crayons...
ScriptUI is like drawing the plans to your house with said crayons...
an this is wear smoke comes out
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more