How can I set the size of the statictext? Or can it even be done? Also, can it be made bold?
Thanks
How to set size of statictext?
-
Paul MR
How to set size of statictext?
Here's one example...
Code: Select allvar dlg2 = new Window( 'dialog', 'Test Window' );
dlg2.preferredSize=[600,100];
dlg2.alignChildren="fill";
dlg2.p1= dlg2.add("panel", undefined, undefined, {borderStyle:"black"});
dlg2.p1.align="fill";
dlg2.p1.alignChildren="fill";
dlg2.p1.orientation = 'column';
dlg2.p1.title = dlg2.p1.add('statictext',undefined,'This some test text');
var g = dlg2.p1.title.graphics;
g.font = ScriptUI.newFont("Arial","BOLD",16);
var d = dlg2.graphics;
d.backgroundColor = d.newBrush(d.BrushType.SOLID_COLOR, [0.50, 0.50, 0.90, 1]);
dlg2.b1 = dlg2.add('button',undefined,'Ok');
dlg2.center();
dlg2.show();
Code: Select allvar dlg2 = new Window( 'dialog', 'Test Window' );
dlg2.preferredSize=[600,100];
dlg2.alignChildren="fill";
dlg2.p1= dlg2.add("panel", undefined, undefined, {borderStyle:"black"});
dlg2.p1.align="fill";
dlg2.p1.alignChildren="fill";
dlg2.p1.orientation = 'column';
dlg2.p1.title = dlg2.p1.add('statictext',undefined,'This some test text');
var g = dlg2.p1.title.graphics;
g.font = ScriptUI.newFont("Arial","BOLD",16);
var d = dlg2.graphics;
d.backgroundColor = d.newBrush(d.BrushType.SOLID_COLOR, [0.50, 0.50, 0.90, 1]);
dlg2.b1 = dlg2.add('button',undefined,'Ok');
dlg2.center();
dlg2.show();
-
ddbell
How to set size of statictext?
Thanks, I was able to get your code to work for my script.
-
ddbell
How to set size of statictext?
Can the font color be changed as well?
Based on the Adobe Java Script Tools Guide (which was written by aliens), there doesn't appear to be a color property for the ScriptUIFont object. Is there a way to change the font color?
Based on the Adobe Java Script Tools Guide (which was written by aliens), there doesn't appear to be a color property for the ScriptUIFont object. Is there a way to change the font color?
-
Paul MR
How to set size of statictext?
And here you are....
Code: Select allvar dlg2 = new Window( 'dialog', 'Test Window' );
dlg2.alignChildren="fill";
dlg2.p1= dlg2.add("panel", undefined, undefined, {borderStyle:"black"});
dlg2.p1.align="fill";
dlg2.p1.alignChildren="fill";
dlg2.p1.orientation = 'column';
dlg2.p1.title = dlg2.p1.add('statictext',undefined,'This some test text');
var g = dlg2.p1.title.graphics;
g.font = ScriptUI.newFont("Arial","BOLD",16);
var d = dlg2.graphics;
d.backgroundColor = d.newBrush(d.BrushType.SOLID_COLOR, [1.0, 1.00, 0.00, 1]);
g.foregroundColor =g.newPen (g.PenType.SOLID_COLOR, [1.00, 0.00, 0.00, 1],lineWidth=1);
dlg2.b1 = dlg2.add('button',undefined,'Ok');
dlg2.center();
dlg2.show();
Code: Select allvar dlg2 = new Window( 'dialog', 'Test Window' );
dlg2.alignChildren="fill";
dlg2.p1= dlg2.add("panel", undefined, undefined, {borderStyle:"black"});
dlg2.p1.align="fill";
dlg2.p1.alignChildren="fill";
dlg2.p1.orientation = 'column';
dlg2.p1.title = dlg2.p1.add('statictext',undefined,'This some test text');
var g = dlg2.p1.title.graphics;
g.font = ScriptUI.newFont("Arial","BOLD",16);
var d = dlg2.graphics;
d.backgroundColor = d.newBrush(d.BrushType.SOLID_COLOR, [1.0, 1.00, 0.00, 1]);
g.foregroundColor =g.newPen (g.PenType.SOLID_COLOR, [1.00, 0.00, 0.00, 1],lineWidth=1);
dlg2.b1 = dlg2.add('button',undefined,'Ok');
dlg2.center();
dlg2.show();
-
jb1er
How to set size of statictext?
Is it possible to change the colour of a button?
btnAs = dialogWin.add("button", [220,5,220+15,5+15], "a");
btnAs.graphics.backgroundColor = btnAs.graphics.newBrush(btnAs.graphics.BrushType.SOLID_COLOR, [0.50, 0.50, 0.90, 1]);
this returns an error "cannot change background color on this type of objects"
thanks for your help
btnAs = dialogWin.add("button", [220,5,220+15,5+15], "a");
btnAs.graphics.backgroundColor = btnAs.graphics.newBrush(btnAs.graphics.BrushType.SOLID_COLOR, [0.50, 0.50, 0.90, 1]);
this returns an error "cannot change background color on this type of objects"
thanks for your help
-
Paul MR
How to set size of statictext?
The only way would be to use 'iconbutton', Mike has an example here..
bb/viewtopic.php?t=3137
bb/viewtopic.php?t=3137
-
jb1er
How to set size of statictext?
I had a look at that, it's a bit annoying to have to create and load some image files just to get a different color, but it will do...
thanks!
thanks!
-
Mike Hale
How to set size of statictext?
If you have CS4 you can turn a group or panel into a button by adding a mouse event handler.
Code: Select allfunction h2d(h) {return parseInt(h,16);}
function getHexColor(){
var result = $.colorPicker( -1 ).toString(16);
if (result != -1){
result = '00000'.substring( 0, 6 - result.length ) + result;
}
return result;
}
createDialog = function ( ) {
var dlg = new Window( 'dialog', 'Color Example Script' );
dlg.colorPnl1 = dlg.add( 'panel', [1,1,50,50],undefined,{borderStyle:'sunken'});
dlg.colorPnl1.graphics.backgroundColor = dlg.colorPnl1.graphics.newBrush( dlg.colorPnl1.graphics.BrushType.SOLID_COLOR,[0,0,0]);
dlg.colorText1 = dlg.add('statictext', undefined, "Click on the 'button' to change it's color" );
dlg.btnPnl = dlg.add( 'panel', undefined );
dlg.btnPnl.orientation = "row";
dlg.btnPnl.alignment = "right";
dlg.btnPnl.preferredSize [ 80, 80 ]
dlg.okBtn = dlg.btnPnl.add( 'button', undefined, 'Ok', { name:'ok' });
dlg.cancelBtn = dlg.btnPnl.add( 'button', undefined, 'Cancel', { name:'cancel' });
return dlg;
};
initializeDialog = function( w ) {
ScriptUI.events.createEvent('MouseEvent');
w.colorPnl1.addEventListener ('mousedown', btnMouseEventHandler, false);
// The Ok and Cancel buttons close this dialog
w.okBtn.onClick = function ( ) { this.parent.parent.close( 1 ); };
w.cancelBtn.onClick = function ( ) { this.parent.parent.close( 2 ); };
}
runDialog = function( w ) {
return w.show( );
};
var win = createDialog();
initializeDialog(win);
runDialog(win);
function btnMouseEventHandler (event) {
try {
var d = FindDialog( this );
var m = event.type// 'mouseover or mouseout
if ( m == 'mousedown' ) {
var c = getHexColor();
if( c != -1){
var r = h2d(c.substring(0,2))/255;
var g = h2d(c.substring(2,4))/255;
var b = h2d(c.substring(4,6))/255;
d.colorPnl1.graphics.backgroundColor = d.colorPnl1.graphics.newBrush( d.colorPnl1.graphics.BrushType.SOLID_COLOR,[r,g,b]);
}
}
}catch (e) {}
}
/*//////////////////////////////////////////////////////////////////////////////
// Function: FindDialog
// Usage: From a deeply grouped dialog item go up til you find the parent dialog
// Input: Current dialog item, an actual item or a group
// Return: top parent dialog
//////////////////////////////////////////////////////////////////////////////*/
function FindDialog( inItem ) {
var w = inItem;
while ( 'dialog' != w.type ) {
if ( undefined == w.parent ) {
w = null;
break;
}
w = w.parent;
}
return w;
}
Code: Select allfunction h2d(h) {return parseInt(h,16);}
function getHexColor(){
var result = $.colorPicker( -1 ).toString(16);
if (result != -1){
result = '00000'.substring( 0, 6 - result.length ) + result;
}
return result;
}
createDialog = function ( ) {
var dlg = new Window( 'dialog', 'Color Example Script' );
dlg.colorPnl1 = dlg.add( 'panel', [1,1,50,50],undefined,{borderStyle:'sunken'});
dlg.colorPnl1.graphics.backgroundColor = dlg.colorPnl1.graphics.newBrush( dlg.colorPnl1.graphics.BrushType.SOLID_COLOR,[0,0,0]);
dlg.colorText1 = dlg.add('statictext', undefined, "Click on the 'button' to change it's color" );
dlg.btnPnl = dlg.add( 'panel', undefined );
dlg.btnPnl.orientation = "row";
dlg.btnPnl.alignment = "right";
dlg.btnPnl.preferredSize [ 80, 80 ]
dlg.okBtn = dlg.btnPnl.add( 'button', undefined, 'Ok', { name:'ok' });
dlg.cancelBtn = dlg.btnPnl.add( 'button', undefined, 'Cancel', { name:'cancel' });
return dlg;
};
initializeDialog = function( w ) {
ScriptUI.events.createEvent('MouseEvent');
w.colorPnl1.addEventListener ('mousedown', btnMouseEventHandler, false);
// The Ok and Cancel buttons close this dialog
w.okBtn.onClick = function ( ) { this.parent.parent.close( 1 ); };
w.cancelBtn.onClick = function ( ) { this.parent.parent.close( 2 ); };
}
runDialog = function( w ) {
return w.show( );
};
var win = createDialog();
initializeDialog(win);
runDialog(win);
function btnMouseEventHandler (event) {
try {
var d = FindDialog( this );
var m = event.type// 'mouseover or mouseout
if ( m == 'mousedown' ) {
var c = getHexColor();
if( c != -1){
var r = h2d(c.substring(0,2))/255;
var g = h2d(c.substring(2,4))/255;
var b = h2d(c.substring(4,6))/255;
d.colorPnl1.graphics.backgroundColor = d.colorPnl1.graphics.newBrush( d.colorPnl1.graphics.BrushType.SOLID_COLOR,[r,g,b]);
}
}
}catch (e) {}
}
/*//////////////////////////////////////////////////////////////////////////////
// Function: FindDialog
// Usage: From a deeply grouped dialog item go up til you find the parent dialog
// Input: Current dialog item, an actual item or a group
// Return: top parent dialog
//////////////////////////////////////////////////////////////////////////////*/
function FindDialog( inItem ) {
var w = inItem;
while ( 'dialog' != w.type ) {
if ( undefined == w.parent ) {
w = null;
break;
}
w = w.parent;
}
return w;
}
-
d3mac123
How to set size of statictext?
Mike, I am trying your code (great as usual!) but I noticed the "color button" only "listens" when it is clicked in its border. For example, clicking the center of the color does not trigger the event listener. Is there a way to make the entire area clickable?
Thanks,
Alex
Thanks,
Alex