Skip to main content
Silly-V
Legend
January 29, 2015
Answered

ScriptUI window.minimized = true; on Mac

  • January 29, 2015
  • 2 replies
  • 5368 views

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();

This topic has been closed for replies.
Correct answer Silly-V

Hmmm... so I guess I am to assume you couldn't get the link above or my example approach working successfully in CC ? If so that's scary, yet unsurprising that they broke certain things?

Silly-V wrote:

it's possible to pass in the configuration of the big palette as an object to be stored in the tiny window, and then to resurrect the element states of the big one when it's maximized, including the window's location so that it appears as if they are appearing back in the last place they were closed at. This could be re-purposed to pop up the big palette in the same location of the tiny one, so that they closer mimic the behavior of the native UI panels.

I am not sure if they are supposed to follow each other, but for me they pop up in different locations, that and they are different widths. I think from a UI standardization standpoint if you are gonna go with this approach they should indeed replace each other in the same location, and retain the same width (even though the height will vary obviously) for some UI congruence.

At least you seemed to like the "fromCharCode" to build an array. ;-)


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, closebutton: false}); w.spacing = 0; w.margins = [0,0,0,0];

        var loc = (SETTINGS.syncLocations) ?  storeObj.bigWindowLocation : storeObj.tinyWindowLocation ;

        w.location = loc;

        var p = w.add('panel'); p.size = [100, 42];

        var btn = p.add('statictext', undefined, 'Maximize');

        this.show = function(){w.show();}

        btn.addEventListener('mousedown' , function(){

            storeObj.tinyWindowLocation = w.bounds;

            var thisPaletteWindow = new paletteWindow(storeObj);

            thisPaletteWindow.show();

            w.close();

        });

    }

    function paletteWindow(setupObj){

        var w = new Window('palette', 'My Panel');

        var loc = (SETTINGS.syncLocations) ?  setupObj.tinyWindowLocation : setupObj.bigWindowLocation;

        w.location = loc;

        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);

        }

        var e = w.add('edittext', undefined, setupObj.edittextContents, {readonly: true}); e.characters = 19;

        t.onDoubleClick = function(){

            if(t.selection != null && t.selection.text != ''){

                e.text = (t.selection.text);

            }

        };

        var g2 = w.add('panel', undefined, 'Window Options'); g2.alignChildren = 'left';

        var r1 = g2.add('radiobutton', undefined, 'Minimize in same place.');

        var r2 = g2.add('radiobutton', undefined, 'Minimize in different places.');

        r1.value = SETTINGS.syncLocations;

        r2.value = !r1.value;

 

        var btn_min = w.add('button', undefined, 'Minimize'); 

        btn_min.onClick = function(){

            SETTINGS.syncLocations = r1.value;

            var thisTinyWindow = new tinyWindow({edittextContents: e.text, tinyWindowLocation: setupObj.tinyWindowLocation, bigWindowLocation: w.location});

            thisTinyWindow.show();

            w.close();

        } 

 

        this.show = function(){w.show();}

    }

    var SETTINGS = {

        syncLocations: true

    };

    var thisTinyWindow = new tinyWindow({edittextContents: '', tinyWindowLocation: [920,514], bigWindowLocation: [860, 350]});

    thisTinyWindow.show();

 

 

myPanel();

2 replies

julioc4816867
Known Participant
March 7, 2015

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

Silly-V
Silly-VAuthor
Legend
March 7, 2015

Yes, I've made a previous example, but it is still in progress. I'll put it up on GitHub when it is complete.

CarlosCanto
Community Expert
Community Expert
January 30, 2015

try adding maximize & minimize creation property buttons to the palette to see if those work.

Silly-V
Silly-VAuthor
Legend
January 31, 2015

I tried the sizes, which didn't seem to make it work, but I also added a minimizeButton and maximizeButton, hoping to get something working.  What I saw was that buttons were added (This is Mac, CS5)  , the maximize button maximized the window to fill entire screen, but the minimize button was completely disabled.  Then, I consulted Peter Kahrel's ScriptUI guide to notice that we can make a Window() with type 'window' , which gave me the minimize button on the Mac, but it minimizes completely to the dock, instead of my desired effect of minimizing into a little rectangle, and floating up there.

Inspiring
February 24, 2015

Have a look at this thread and example:

Dynamic script UI changes

There are a few others that are relative in the InDeisgn forum also. Hope it helps your efforts.