Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

ScriptUI auto-hide layout and styling

$
0
0

Hello,

I'm having troubles with a script (actually I'm running it in Photoshop, but I'm posting here because this place is densely packaged of ScriptUI experts ).

 

// Test script
var winRes = "dialog { \          title: 'Styling test', \          orientation: 'row', \          alignChildren: ['fill', 'top'], \          firstPanel: Panel {text: 'First', \                    alignChildren: ['center', 'center'] \                    size: [250, 200] \                    openButton: IconButton { title: 'Open new panel', size: [150, 30], properties: {toggle: true}}, \                    cancelButton: Button { text: 'Cancel', properties:{ name:'cancel'}}, \                    okButton: Button { text: 'OK', properties:{name:'ok'}}, \          } \}"
 var win = new Window(winRes) 
win.firstPanel.openButton.onClick = function() {          if (this.value) {                    var secondPanel = win.add('panel', undefined, 'Second');                    secondPanel.size = [150, 200];                    secondPanel.margins = 15;                    var stTitle = secondPanel.add('statictext', undefined, 'Title');                    var stText = secondPanel.add('statictext', undefined, undefined, {multiline: true, scrolling: true});                    var message = "list of things;\nlist of things;\nlist of things;\nlist of things";                    stText.size = [100,100];                    stText.text = message;                    // How to style the statictext?                        // given that:                    // alert(win.secondPanel.stText.text) // undefined                    // alert(win.children[1].children[1].text) // "list of things..."                    //win.children[1].children[1].graphics.backgroundColor = win.children[1].children[1].graphics.newBrush(win.children[1].children[1].graphics.BrushType.SOLID_COLOR, [0.5, 0.0, 0.0]);                    win.layout.layout(true)          }else{                    win.remove(1)                    win.layout.layout(true)          }} 
win.show();

 

Basically, it opens a Dialog with a panel and some placeholder buttons.

When you click on one of them, a second panel should be created on the right of the first one and the Dialog resized accordingly.

 

I've two problems:

1. The first panel gets resized, and it shouldn't.

2. I'd like to style the second panel statictext background, but apparently I can't (as you see in the code's comments, I've to reference it as win.children[1].children[1])

 

For the first problem, I'm out of answers; for the second one, I thought it could be because I can't style a text that is not yet rendered, but any code that I put after the win.layout.layout(true) is never reached.

 

Any suggestion is greatly appreciated!

TIA

 

Davide


Viewing all articles
Browse latest Browse all 15932

Trending Articles



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