makeshift tabbed GUI

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

Patrick

makeshift tabbed GUI

Post by Patrick »

Here is a simple example of how to make a dialog box with multiple pages of content. Note that the forum add's a extra space to the end of every line, so you will need to remove those manually (in the dlg variable, atleast) or else this will likely return an error.

Code: Select allvar dlg = new Window("dialog{text:'Tabbed Interface',bounds:[100,100,520,360],\
      button01:Button{bounds:[10,10,110,30] , text:'tab 1' },\
      button02:Button{bounds:[110,10,210,30] , text:'tab 2' },\
      button03:Button{bounds:[210,10,310,30] , text:'tab 3' },\
      button04:Button{bounds:[310,10,410,30] , text:'tab 4' },\
      page01:Panel{bounds:[10,40,410,250] , text:'page 1' ,properties:{borderStyle:'etched',su1PanelCoordinates:true}\
      },\
      page02:Panel{bounds:[10,40,410,250] , text:'page 2' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},\
         radiobutton0:RadioButton{bounds:[90,40,191,61] , text:'RadioButton Text' },\
         radiobutton1:RadioButton{bounds:[70,70,171,91] , text:'RadioButton Text' },\
         radiobutton2:RadioButton{bounds:[140,120,241,141] , text:'RadioButton Text' },\
         radiobutton3:RadioButton{bounds:[260,40,361,61] , text:'RadioButton Text' }\
      },\
      page03:Panel{bounds:[10,40,410,250] , text:'page 3' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},\
         edittext0:EditText{bounds:[40,30,141,46] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}},\
         edittext1:EditText{bounds:[100,60,201,76] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}},\
         edittext2:EditText{bounds:[20,140,121,156] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}},\
         edittext3:EditText{bounds:[60,90,161,106] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}}\
      },\
      page04:Panel{bounds:[10,40,410,250] , text:'page 4' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},\
         edittext4:EditText{bounds:[280,50,381,66] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}},\
         edittext5:EditText{bounds:[280,80,381,96] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}},\
         edittext6:EditText{bounds:[280,120,381,136] , text:'<Lorem ipsum dolor...>' ,properties:{multiline:false,noecho:false,readonly:false}},\
         radiobutton4:RadioButton{bounds:[80,60,181,81] , text:'RadioButton Text' },\
         radiobutton5:RadioButton{bounds:[80,100,181,121] , text:'RadioButton Text' },\
         radiobutton6:RadioButton{bounds:[80,150,181,171] , text:'RadioButton Text' }\
      }\
};");

// start showing just page 1
dlg.page01.visible = true;
dlg.page02.visible = false;
dlg.page03.visible = false;
dlg.page04.visible = false;

// show page 1
dlg.button01.onClick = function() {
   try {
      dlg.page02.visible = false;
      dlg.page03.visible = false;
      dlg.page04.visible = false;
      dlg.page01.visible = true;            

   } catch (e) {
      // do nothing on error
   };
};

// show page 2
dlg.button02.onClick = function() {
   try {
      dlg.page01.visible = false;
      dlg.page03.visible = false;
      dlg.page04.visible = false;
      dlg.page02.visible = true;            

   } catch (e) {
      // do nothing on error
   };
};

// show page 3
dlg.button03.onClick = function() {
   try {
      dlg.page01.visible = false;
      dlg.page02.visible = false;
      dlg.page04.visible = false;
      dlg.page03.visible = true;            

   } catch (e) {
      // do nothing on error
   };
};

// show page 4
dlg.button04.onClick = function() {
   try {
      dlg.page01.visible = false;
      dlg.page02.visible = false;
      dlg.page03.visible = false;            
      dlg.page04.visible = true;            

   } catch (e) {
      // do nothing on error
   };
};

// display the window to the user
dlg.center();
dlg.show();


Regards,
Patrick