Skip to main content
gregreser
Legend
October 27, 2012
Answered

Save location and size of tabbed pallette

  • October 27, 2012
  • 1 reply
  • 1006 views

I am creating a new tabbed palette and I would like to save changes made by the user for position and size so they can be applied the next time Bridge is opened.  Instead of the tabbed palette always opening in the lower right, e.g, paletteColumn [right, bottom] and with a fixed width,  I want it to open in the location and size that user set in their last session.  If the user drags the tabbed palette to another location or drags the width, I want to read that information at close and write it to a temp file where it will be read at the next startup.

It looks like I should be able to access a tabbed palette's properties using app.document.palettes[index], but I can't get anything useful to return.

Thanks.

This topic has been closed for replies.
Correct answer Paul Riggott

Interesting, it might be easier to tell the user to create a new workspace

It seems that the location (row, column) can't be extracted for some reason?

Also another bug in Bridge CS6, it will crash if you close the palette.

Here is some test code I was using....

//#target bridge
test();

function test(){
var SP = new TabbedPalette( app.document, "Test", "testTab", "script", "left", "top");
SP.content.onResize = function(){
  var b = this.bounds;
  pnl.bounds = b;
  this.layout.resize(true);
  SP.content.layout.layout(true);
}
var pnl = SP.content.add("panel", undefined , "");
pnl.alignChildren = ["center", "fill"];

var mainBtnGp = pnl.add("group");
mainBtnGp.orientation = "column";

var titleGp = mainBtnGp.add("group");
titleGp.alignment ="column";
var title = titleGp.add("statictext", undefined, "Test Panel");
var g = title.graphics;
g.font = ScriptUI.newFont ("Arial", 20);
    var gp90 = mainBtnGp.add("group");
    var bnds = gp90.add('button',undefined,'Bounds');
var gp110 = mainBtnGp.add("group");
    gp110.alignment ="column";
    var dl = [ "Upper Left","Upper Right","Center","Lower Left", "Lower Right","Remove Palette"];
ulBtn = gp110.add("dropdownlist", undefined, dl);
    ulBtn.selection=0;

    bnds.onClick=function(){
      alert("Panel Bounds \r" +SP.content.bounds.toString() +
    "\rTitle = " +SP.title + "\rID = " +SP.id + "\rRow = " + SP.paletteRow +"\rColumn = " + SP.paletteColumn);
        }
ulBtn.onChange = function(){
        switch(this.selection.index){
  case 0 :SP.setLocation("left", "top"); break;
        case 1 :SP.setLocation("right", "top");break;
        case 2 : SP.setLocation("center", "middle");break;
        case 3 : SP.setLocation("left", "bottom");break;
        case 4 : SP.setLocation("right", "bottom");break;
        case 5 : SP.remove();break;
        default : break;
        }
}
SP.content.layout.layout(true);
}

1 reply

Paul Riggott
Paul RiggottCorrect answer
Inspiring
October 28, 2012

Interesting, it might be easier to tell the user to create a new workspace

It seems that the location (row, column) can't be extracted for some reason?

Also another bug in Bridge CS6, it will crash if you close the palette.

Here is some test code I was using....

//#target bridge
test();

function test(){
var SP = new TabbedPalette( app.document, "Test", "testTab", "script", "left", "top");
SP.content.onResize = function(){
  var b = this.bounds;
  pnl.bounds = b;
  this.layout.resize(true);
  SP.content.layout.layout(true);
}
var pnl = SP.content.add("panel", undefined , "");
pnl.alignChildren = ["center", "fill"];

var mainBtnGp = pnl.add("group");
mainBtnGp.orientation = "column";

var titleGp = mainBtnGp.add("group");
titleGp.alignment ="column";
var title = titleGp.add("statictext", undefined, "Test Panel");
var g = title.graphics;
g.font = ScriptUI.newFont ("Arial", 20);
    var gp90 = mainBtnGp.add("group");
    var bnds = gp90.add('button',undefined,'Bounds');
var gp110 = mainBtnGp.add("group");
    gp110.alignment ="column";
    var dl = [ "Upper Left","Upper Right","Center","Lower Left", "Lower Right","Remove Palette"];
ulBtn = gp110.add("dropdownlist", undefined, dl);
    ulBtn.selection=0;

    bnds.onClick=function(){
      alert("Panel Bounds \r" +SP.content.bounds.toString() +
    "\rTitle = " +SP.title + "\rID = " +SP.id + "\rRow = " + SP.paletteRow +"\rColumn = " + SP.paletteColumn);
        }
ulBtn.onChange = function(){
        switch(this.selection.index){
  case 0 :SP.setLocation("left", "top"); break;
        case 1 :SP.setLocation("right", "top");break;
        case 2 : SP.setLocation("center", "middle");break;
        case 3 : SP.setLocation("left", "bottom");break;
        case 4 : SP.setLocation("right", "bottom");break;
        case 5 : SP.remove();break;
        default : break;
        }
}
SP.content.layout.layout(true);
}

gregreser
gregreserAuthor
Legend
October 28, 2012

Thanks for the help with this Paul.

You are right, I might just tell users to create a new workspace.  I was also thinking I could include a "change palette location", similar to your dropdownlist, option which would record the users choice.  I could also record the bounds if they resize the palette column.

Thanks again.

Greg