Skip to main content
Inspiring
January 17, 2014
Answered

ScriptUI resizing

  • January 17, 2014
  • 1 reply
  • 896 views

Hi

I'm working on a simple conversion tool for indesign to html5. It begins to do the job but I have some problems with the UI.

First one: when I click on the "New" button, the new "tagLine" appears always at the bottom of the stack. Is there a way to make it appears just below the "tagLine" on wich I click?

Next one: when I click on the "Delete" button, the "tagLine" is well removed but others "tagLines" stay at their places. Is there a way to rearrange the remaining "tagLines" withouth the empty spaces?

Any help welcome

A picture is always better than a long speach:

The script:

var count = 0;

var lineUI = new Array();

var myPalette = new Window('palette', 'Ma palette');

initializePalette();

newTagLine();

myPalette.show();

function initializePalette() {

    if (myPalette != null) {

        var defaultButtons = myPalette.add('group', undefined, 'defaultButtons');

        defaultButtons.orientation = 'row';

        defaultButtons.alignment = 'right';

        defaultButtons.cancelBt = defaultButtons.add('button', undefined, 'Cancel', {name: 'cancel'});

        defaultButtons.cancelBt.onClick = function () { myPalette.close(); };

        defaultButtons.startBt = defaultButtons.add('button', undefined, 'Start Process', {name: 'start'});

        defaultButtons.startBt.onClick = function () { myPalette.close(); ParagraphStylesManagment(app.selection[0].parentStory.paragraphs); };

        myPalette.layout.layout(true);

        myPalette.layout.resize();

    }

}

function newTagLine() {

    if (myPalette != null) {

        var i = count;

        var myUiLineName = 'lineUI' + count;

        lineUI = myPalette.add('group', undefined, myUiLineName);

        lineUI.orientation = 'row';

        lineUI.upperTagName = lineUI.add('dropdownlist', undefined, ['--- none ---', 'book', 'part', 'chapter', 'section', 'sub-section', 'sub-sub-section', 'ol', 'ul']);

        lineUI.upperTagName.selection = 0;

        lineUI.tagName = lineUI.add('dropdownlist', undefined, ['--- none ---', 'h1', 'h2', 'h3', 'li', 'p']);

        lineUI.tagName.selection = 0;

        lineUI.letterSizeStatus = lineUI.add('checkbox', undefined, 'Size');

        lineUI.letterSize = lineUI.add('edittext', undefined, '');

        lineUI.letterSize.characters = 3;

        lineUI.familyStatus = lineUI.add('checkbox', undefined, 'Family');

        lineUI.family = lineUI.add('edittext', undefined, '');

        lineUI.family.characters = 10;

        lineUI.fontStyleStatus = lineUI.add('checkbox', undefined, 'FontStyle');

        lineUI.fontStyle = lineUI.add('edittext', undefined, '');

        lineUI.fontStyle.characters = 10;

        lineUI.catchBt = lineUI.add('button', undefined, 'Catch', {name: 'catchTag'});

        lineUI.catchBt.onClick = function () { catchTagProperties(i); };

        lineUI.newBt = lineUI.add('button', undefined, 'New', {name: 'newTag'});

        lineUI.newBt.onClick = function () { newTagLine(); };

        lineUI.deleteBt = lineUI.add('button', undefined, 'Delete', {name: 'deleteTag'});

        lineUI.deleteBt.onClick = function () { deleteTagLine(i); };

        myPalette.layout.layout(true);

        myPalette.layout.resize();

        count += 2;

    }

}

function deleteTagLine(counter) {

    lineUI[counter].hide();

    myPalette.layout.layout(true);

    myPalette.layout.resize();

}

This topic has been closed for replies.
Correct answer ID Script

Hi

Please made few changes on your script like this:

function deleteTagLine(counter) {

   myPalette.remove(lineUI[counter]);

   myPalette.layout.layout();

   myPalette.layout.resize();

   myPalette.bounds = [myPalette.bounds[0],myPalette.bounds[1],myPalette.bounds[2],(myPalette.bounds[3]-38)];

}

Velladurai.G

1 reply

ID ScriptCorrect answer
Participant
January 21, 2014

Hi

Please made few changes on your script like this:

function deleteTagLine(counter) {

   myPalette.remove(lineUI[counter]);

   myPalette.layout.layout();

   myPalette.layout.resize();

   myPalette.bounds = [myPalette.bounds[0],myPalette.bounds[1],myPalette.bounds[2],(myPalette.bounds[3]-38)];

}

Velladurai.G

LeftHeadAuthor
Inspiring
January 21, 2014

Great !!!

Thanks alot