How do you change the button colour?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Paul MR

How do you change the button colour?

Post by Paul MR »

As the title says how is it done in UI?

Code: Select allvar dlg = new Window('dialog', Colour Test',[100,100,480,245]);
dlg.msgPnl = dlg.add('panel', [25,15,355,130], '');
dlg.msgPnl.titleSt = dlg.msgPnl.add('statictext', [15,15,400,60], 'Do Not Press The OK Button');
dlg.msgPnl.button =dlg.msgPnl.add('button',[102,60,200,100] , 'Ok');
dlg.msgPnl.titleSt.graphics.font = ScriptUI.newFont("Times","ITALIC",14);
g = dlg.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.00, 1]);
g.backgroundColor = myBrush;
dlg.show();
Patrick

How do you change the button colour?

Post by Patrick »

There is no color property for a dialog button, so you are unable to change it. The only option I can think of would be to have a iconbutton object, and create a image for each color you want. You can have your script change the iconbutton graphic on demand.

Patrick
Paul MR

How do you change the button colour?

Post by Paul MR »

Thanks Patrick, maybe its time to learn how to use Flash with Photoshop UI
Patrick

How do you change the button colour?

Post by Patrick »

Paul MR wrote:Thanks Patrick, maybe its time to learn how to use Flash with Photoshop UI

Yeah, the examples they showed of Flash / FLEX for UI when CS3 first launched looked like they would be much, much better for doing stuff like this. Main problem (for me atleast) is Flex costs money .

If you get going with it, I would love to see some examples of what you come up with.

Patrick
Paul MR

How do you change the button colour?

Post by Paul MR »

looks like you can do it for FREE Patrick..

http://learn.adobe.com/wiki/display/Fle ... ed+to+Flex ... ed+to+Flex
Patrick

How do you change the button colour?

Post by Patrick »

I looked into that back when CS3 came out, and if I am correct it is just the command like compiler that is free. If you want to visually build menus, you need FLEX Builder. I didn't get to far into it, so I could be mistaken.

I downloaded the 60 day trial of FLEX builder over the weekend, hoping to install it this week if I have time and play around with it.

Patrick
Paul MR

How do you change the button colour?

Post by Paul MR »

Yes you are correct, but you can use any text editor then use the compiler.
I downloaded the trial version to play with and I'am struggling with it!
The main source of documentation seems to be the one script in the samples folder. I managed to use editboxs and get data back from Photoshop. Checkboxs are fairly easy to implement, BUT still havn't got my head around getting data/lists from Photoshop into Comboboxs.

Very crude first try : opening a document...
jsx code..
Code: Select all#target photoshop
var res =
"dialog {      \
   fp: FlashPlayer { preferredSize: [590, 140] },   \
}";

var w = new Window (res,"Open Selected File");
w.margins = [0,0,0,0];
w.onShow = function () {
   var myJSXPath = whereAmI();
   var mySWFFile = myJSXPath + "/main.swf"
   var movieToPlay = new File (mySWFFile);
   try {
      this.fp.loadMovie (movieToPlay);
      this.fp.exitApp = exitApp;
      this.fp.Okay = Okay;
      this.fp.whereAmI = whereAmI;      
      this.fp.selectFile = selectFile;

   } catch (e) {
      alert ("Load Movie function failed: " + e);
   }
}
w.show();

function whereAmI(){
   var where
   try {
      app.documents.test();
   }
   catch (err){
      where = File(err.fileName);
   }
   return where.path;
}
function Okay(){
   //Do yer stuff
   app.open(myOpenDoc[0]);
   exitApp();
}
function selectFile() {
 myOpenDoc = openDialog();
   return  decodeURI(myOpenDoc);
}
function exitApp() {
      try{
         w.close ();
      }
      catch(e) {
         alert(e);
      }
}


mxml code..
Code: Select all<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Canvas label="New Document" width="571" height="104" x="10" y="25" borderColor="#F884F1" color="#060606" backgroundColor="#696963">
<mx:Script>
      <![CDATA[
        import mx.managers.CursorManager;
        import mx.controls.Alert;
      import mx.collections.ArrayCollection;
                         
        public function callExitApp():void {
         var f:String = "exitApp";
            var m:String = ExternalInterface.call(f);
            trace(m);
            }
             public function callOK():void {
         var f:String = "Okay";
            var m:String = ExternalInterface.call(f);
            trace(m);
            }
      public function browseFile():void {
         txtDocName.text = '';
         var f:String = "selectFile";
           var m:String = ExternalInterface.call(f);
           trace(m);
          
           var myDoc:String = m.toString();
           txtDocName.text = myDoc;
      } 
         
      ]]>
   </mx:Script>
<mx:Label x="12" y="12" text="Document:" id="lblHistogramTargetDoc" width="70" visible="true" color="#FCFF03"/>
 <mx:Button x="484" y="10" label="Browse" id="btnBrowse" click="browseFile();"/>
<mx:TextInput x="85" y="10" width="391" id="txtDocName" editable="false"/>
   <mx:Button x="12" y="53" label="Ok" id="btnOK" click="callOK();" width="195" fillAlphas="[1.0, 1.0]" fillColors="[#0C11E9, #0C11E9, #2BE90C, #2BE90C]"/>
   <mx:Button x="357" y="53" label="Cancel" id="btnCancel" click="callExitApp();" width="195" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#1A2AF6, #1A1FF6, #F61A1A, #F61A1A]"/>
</mx:Canvas>
</mx:Application>



Any help getting a Combobox populated would be great (Font List etc).
Paul MR

How do you change the button colour?

Post by Paul MR »

Here's yet another attempt Patrick.

jsx code..
Code: Select all#target photoshop
var res =
"dialog {      \
   fp: FlashPlayer { preferredSize: [348, 365] },   \
}";
var w = new Window (res,"Font Names");
w.margins = [0,0,0,0];

w.onShow = function () {
   var myJSXPath = whereAmI();
   var mySWFFile = myJSXPath + "/main.swf"
   var movieToPlay = new File (mySWFFile);
   try {
      this.fp.loadMovie (movieToPlay);
      this.fp.exitApp = exitApp;   
      this.fp.callSetup = callSetup; 
      this.fp.callSetup2 = callSetup2;
      this.fp.callSetup3 = callSetup3;
      this.fp.whereAmI = whereAmI;      
   } catch (e) {
      alert ("Load Movie function failed: " + e);
   }
}


w.show();

function whereAmI(){
   var where
   try {
      app.documents.test();
   }
   catch (err){
      where = File(err.fileName);
   }
   return where.path;
}

function exitApp() {
      try{
         w.close ();
      }
      catch(e) {
         alert(e);
      }
}

function callSetup() {
      try{
         var list1 = new Array;
         for (var i=0,len=app.fonts.length;i<len;i++) {
            list1.push( app.fonts.name);
            }
return(list1);
      
      }
      catch(e) {
         alert(e);
      }
}

function callSetup2() {
      try{
         var list2 = new Array;
         for (var i=0,len=app.fonts.length;i<len;i++) {
            list2.push( app.fonts.postScriptName);
            }
   
return(list2);
      
      }
      catch(e) {
         alert(e);
      }
}
function callSetup3() {
      try{
         var list3 = new Array;
         for (var i=0,len=app.fonts.length;i<len;i++) {
            list3.push( app.fonts.family);
            }
   
return(list3);
      
      }
      catch(e) {
         alert(e);
      }
}


mxml code..
Code: Select all<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="348" height="365" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#A8A5A5, #D5C220]" creationComplete="callSetup()">
<mx:Script>
   <![CDATA[
import mx.rpc.events.AbstractEvent;
import mx.controls.Alert;
import mx.events.DropdownEvent;
import flash.external.ExternalInterface;
import mx.events.FlexEvent;
[Bindable]
        public var comboData1: Array;
[Bindable]
        public var comboData2: Array;
[Bindable]       
        public var comboData3: Array;


public function callSetup():void
{   
var f:Array = ["callSetup"];
var m:Array = ExternalInterface.call(f[0]);
trace(m);
var fonts:Array = new Array;
comboData1 = m;
callSetup2();   
}
public function callSetup2():void
{   
var f:Array = ["callSetup2"];
var m:Array = ExternalInterface.call(f[0]);
trace(m);
var fonts:Array = new Array;
comboData2 = m;
callSetup3();
}
public function callSetup3():void
{   
var f:Array = ["callSetup3"];
var m:Array = ExternalInterface.call(f[0]);
trace(m);
var fonts:Array = new Array;
comboData3 =m;
}
public function callExit():void
{
var f:String = "exitApp";
var m:String = ExternalInterface.call(f);
trace(m);
}
private function changeEvt1(event:Event):void {
   //        Alert.show(combo1.selectedIndex.toString());
           combo2.selectedIndex = combo1.selectedIndex;
           combo3.selectedIndex = combo1.selectedIndex;
}
private function changeEvt2(event:Event):void {
           combo1.selectedIndex = combo2.selectedIndex;
           combo3.selectedIndex = combo2.selectedIndex;
}
private function changeEvt3(event:Event):void {
           combo1.selectedIndex = combo3.selectedIndex;
           combo2.selectedIndex = combo3.selectedIndex;
}
   ]]>
</mx:Script>
   <mx:ComboBox x="38" y="69" width="281" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#FDFAFA, #FA0707, #0707FA, #FDFBFB]" id="combo1" dataProvider="{comboData1}" change="changeEvt1(event)"></mx:ComboBox>
   <mx:ComboBox x="38" y="141" width="281" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#FBF9F9, #FF0101, #0303FF, #FEFCFC]" id="combo2" dataProvider="{comboData2}" change="changeEvt2(event)"></mx:ComboBox>
   <mx:ComboBox x="38" y="215" width="281" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#FFFDFD, #FC0000, #000CFC, #FEFDFD]" id="combo3" dataProvider="{comboData3}" change="changeEvt3(event)"></mx:ComboBox>
   <mx:Label x="38" y="27" text="Font name" width="173" height="34" id="lab1" fontSize="30" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
   <mx:Text x="38" y="99" text="Postscript Name" width="271" height="34" id="txt2" fontFamily="Arial" fontSize="30" fontWeight="bold" fontStyle="italic" textDecoration="normal"/>
   <mx:Text x="38" y="171" text="Family Name" width="281" height="36" id="txt3" fontFamily="Arial" fontWeight="bold" fontStyle="italic" fontSize="30"/>
   <mx:Text x="100" y="312" text="Compliments of Paul R" width="148" id="txt4" fontWeight="bold" fontStyle="italic" color="#FB2104"/>
   <mx:Button x="146" y="269" label="Exit" id="btnClose" click="callExit();" fillAlphas="[1.0, 1.0]" fillColors="[#070707, #070707, #FA0404, #FB0404]" themeColor="#1200FF" color="#F8FBFC" borderColor="#020202"/>
   
</mx:Application>