Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Changing the text in a scriptUI window

$
0
0

I'm sure it's trivial, but i cannot get it.

I've got his window displaying my document's name and a button that triggers an action (init)

When going to another illustrator document, since my init action checks the document's name, i'd love the script window to display the right name to avoid confusion.

 

I know how to build a dialogue, but i don't know how to update part of it (let's say a statictext)

 

see the code here, doing nothing but alert(doctitle) on click :

 

/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */

/*global $, Folder*/

 

 

/*****************

Script Test

Par Franck Payen mars 2014

http://fr32c.free.fr

******************/

 

 

var doc; // document actif

var docTitle; // titre du document actif

 

 

function displayUI() {

   

    var dialogue = new Window ("palette", "Afficher les calques ", undefined, {closeButton:true, resizeable: true});

    dialogue.orientation = "column";

    dialogue.alignChildren = "fill";

    dialogue.margins = 10;

    dialogue.location = [0,40];

    dialogue.preferredsize = [200, 400];

   

    // onResize needed on Mac OS X

    dialogue.onResizing = dialogue.onResize = function () {this.layout.resize ();}

   

       

    var groupe0 = dialogue.add ("group", undefined);

    groupe0.orientation = "column";

    groupe0.alignChildren = "fill";

    var monDocTitle = groupe0.add ("statictext", undefined, docTitle);  

 

 

    var groupe2 = dialogue.add ("group", undefined);

    groupe2.orientation = "column";

    groupe2.alignChildren = "fill";

   

    var boutonInit = groupe2.add ("button", undefined, "Reinitialiser");  

 

 

    boutonInit.onClick = function (){       

        var messageBT = new BridgeTalk();

        messageBT.target = "illustrator";

        var messageBTcorps = "initScript()";

        messageBT.body = messageBTcorps;

        messageBT.send();

    };

   

     dialogue.onClose = function (){

        dialogue.hide();

    };

 

 

    //alert (dialogue); //will work and return [object Window]

   

    dialogue.show();

   

};

 

 

 

 

function initScript(){

    if (app.documents.length == 0){

        alert("Merci d'ouvrir un document avant de lancer ce script.\nL'opération a été interrompue.", "Pas de document ouvert");

        return;

    };

   

    doc = app.activeDocument;

    docTitle = app.activeDocument.name.split(".")[0];

   

    alert(docTitle);

   

    //alert (dialogue); //won't work and refuse to launch the script

   

//    displayUI(); // v1, lance le display après l'initialisation. Scindé pour utiliser le bouton réinitialiser.

}

 

 

#target Illustrator

#targetengine main

 

 

var versionAi = new Number (app.version.slice (0,2));

if (versionAi > 12){

    initScript();

    displayUI();

};

else

if (versionAi < 13){

   alert("Ce script n'es pas compatible avec Illustrator CS2 ou des versions plus anciennes.\nL'opération a été interrompue.", "Version incompatible");

};


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>