Skip to main content
YaoyongYu
Known Participant
January 29, 2016
Answered

icon button_invalid image data

  • January 29, 2016
  • 2 replies
  • 2444 views

var w = new Window ("dialog");

  w.orientation = "row";

  var f = File ("C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\AMT\LMResources s\ps.ico")

w.add ("iconbutton" , undefined, f );  // a

  w.add ("iconbutton" , undefined, f, {style: "toolbutton"});  // b

  var t1 = w.add ("iconbutton" , undefined, f, {style: "toolbutton" , toggle: true});  // c

  var t2 = w.add ("iconbutton" , undefined, f, {style: "toolbutton" , toggle: true});  // d

  t2.value = true;

w.show ();

This topic has been closed for replies.
Correct answer Pedro Cortez Marques

Hi

You can only use PNG or JPG.

And in the case of iconbutton, you must use ScriptUI.newImage(File("path")) and not File

var w = new Window ("dialog"); 

  w.orientation = "row"; 

  var f = File (Folder.desktop + "/imageName.png"); // only png or jpg

w.add ("iconbutton" , undefined, f );  // a 

  w.add ("iconbutton" , undefined, ScriptUI.newImage(f), {style: "toolbutton"});  // b 

  var t1 = w.add ("iconbutton" , undefined, ScriptUI.newImage(f), {style: "toolbutton" , toggle: true});  // c 

  var t2 = w.add ("iconbutton" , undefined, ScriptUI.newImage(f) ,{style: "toolbutton" , toggle: true});  // d 

  t2.value = true; 

w.show ();

2 replies

tssee
Inspiring
March 3, 2017

Pedro

It works very well

thank you

Pedro Cortez Marques
Pedro Cortez MarquesCorrect answer
Legend
February 1, 2016

Hi

You can only use PNG or JPG.

And in the case of iconbutton, you must use ScriptUI.newImage(File("path")) and not File

var w = new Window ("dialog"); 

  w.orientation = "row"; 

  var f = File (Folder.desktop + "/imageName.png"); // only png or jpg

w.add ("iconbutton" , undefined, f );  // a 

  w.add ("iconbutton" , undefined, ScriptUI.newImage(f), {style: "toolbutton"});  // b 

  var t1 = w.add ("iconbutton" , undefined, ScriptUI.newImage(f), {style: "toolbutton" , toggle: true});  // c 

  var t2 = w.add ("iconbutton" , undefined, ScriptUI.newImage(f) ,{style: "toolbutton" , toggle: true});  // d 

  t2.value = true; 

w.show ();

tssee
Inspiring
February 2, 2016

Pedro thanks for this

iconbutton work properly

but I have a problem

when you apply iconbutton button cancel

this does not work !!!

how can I fix?

Pedro Cortez Marques
Legend
February 2, 2016

Hi

for example, if you want to close panel on inconbutton 't2' you can use onClick function containing that code and put it before the w.show()

t2.onClick = function() {

    w.close();

}

w.show ();