Table of Contents

Introduction
Who Should Read This?
How Does It Work?
Download(s)
System and Software Requirements
Adobe Photoshop Reserved Words

Tutorials
Overview
  1. Starting a Flex Project
  2. Hello World Panel
  3. Placing the CSXS Library

  4. Shortcut Buttons Panel
    1. JavaScript
    2. Design the Panel
    3. ActionScript
    4. Photoshop Persistent
    5. CSXS Logger AIR Debugger (Optional)

  5. Setting Up Script Listener

  6. Color Picker Panel
    1. JavaScript
    2. Design the Panel
    3. Find Character ID Code to Register Events
    4. ActionScript
    5. Create Custom Icons

  7. Flickr Search Panel
    1. Design the Panel
    2. Create a Flickr Service
    3. Design a Custom Module
    4. Modify Panel's Properties
    5. Connect on Preferences

  8. Per Layer Metadata Panel
    1. View Metadata
    2. JavaScript
    3. Find Character ID Code to Register Events
    4. Designing the Panel
    5. ActionScript
    6. Using Photomerge
Other Samples
Best Practices
Frequently Asked Questions
Acronyms and Definitions
Links
Adobe® Photoshop® Panel Developer's Guide

Color Picker Panel: Find Character ID Code to Register Events

The third part of the Color Picker Panel is finding the character ID code associated with actions/events in Adobe Photoshop. The actions/events that the developer will obtain is resetting the foreground and background color, changing the foreground color, and changing the background color. The result is a JavaScript (JSX) output log showing the functions and character ID code of the events to reset the foreground and background color, changing the foreground color, and changing the background color.

Instructions:

  1. Complete Setting Up Script Listener.
  2. Open Adobe Photoshop.
  3. Press d on the keyboard to set the Default Foregrounds and Backgrounds Color to a black foreground and white background on the Tools Palette or click on the top-right icon as seen below found on the Tools Palette:
  4. Change the foreground color in the Color Picker (Foreground Color) dialog to white.
  5. Press OK.
  6. Change the background color in the Color Picker (Background Color) dialog to black.
  7. Press OK.
  8. Close Adobe Photoshop.
  9. Open ScriptingListenerJS.log on the Desktop with a text editor.
  10. The code within ScriptingListenerJS.log should be similar to below:
    // =======================================================
    var idRset = charIDToTypeID( "Rset" );
       var desc26 = new ActionDescriptor();
       var idnull = charIDToTypeID( "null" );
          var ref18 = new ActionReference();
          var idClr = charIDToTypeID( "Clr " );
          var idClrs = charIDToTypeID( "Clrs" );
          ref18.putProperty( idClr, idClrs );
       desc26.putReference( idnull, ref18 );
    executeAction( idRset, desc26, DialogModes.NO );
    
    // =======================================================
    var idsetd = charIDToTypeID( "setd" );
       var desc27 = new ActionDescriptor();
       var idnull = charIDToTypeID( "null" );
          var ref19 = new ActionReference();
          var idClr = charIDToTypeID( "Clr " );
          var idFrgC = charIDToTypeID( "FrgC" );
          ref19.putProperty( idClr, idFrgC );
       desc27.putReference( idnull, ref19 );
       var idT = charIDToTypeID( "T   " );
          var desc28 = new ActionDescriptor();
          var idH = charIDToTypeID( "H   " );
          var idAng = charIDToTypeID( "#Ang" );
          desc28.putUnitDouble( idH, idAng, 0.000000 );
          var idStrt = charIDToTypeID( "Strt" );
          desc28.putDouble( idStrt, 0.000000 );
          var idBrgh = charIDToTypeID( "Brgh" );
          desc28.putDouble( idBrgh, 100.000000 );
       var idHSBC = charIDToTypeID( "HSBC" );
       desc27.putObject( idT, idHSBC, desc28 );
    executeAction( idsetd, desc27, DialogModes.NO );
    
    // =======================================================
    var idsetd = charIDToTypeID( "setd" );
       var desc29 = new ActionDescriptor();
       var idnull = charIDToTypeID( "null" );
          var ref20 = new ActionReference();
          var idClr = charIDToTypeID( "Clr " );
          var idBckC = charIDToTypeID( "BckC" );
          ref20.putProperty( idClr, idBckC );
       desc29.putReference( idnull, ref20 );
       var idT = charIDToTypeID( "T   " );
          var desc30 = new ActionDescriptor();
          var idH = charIDToTypeID( "H   " );
          var idAng = charIDToTypeID( "#Ang" );
          desc30.putUnitDouble( idH, idAng, 0.000000 );
          var idStrt = charIDToTypeID( "Strt" );
          desc30.putDouble( idStrt, 0.000000 );
          var idBrgh = charIDToTypeID( "Brgh" );
          desc30.putDouble( idBrgh, 0.000000 );
       var idHSBC = charIDToTypeID( "HSBC" );
       desc29.putObject( idT, idHSBC, desc30 );
    executeAction( idsetd, desc29, DialogModes.NO );

    Code Walkthrough: There are three parts of the code generated by actions/events made in Adobe Photoshop:

    1. Reset the foreground and background color
    2. Set the foreground color
    3. Set the background color

    There is a special four character ID code placed as a parameter of the function charIDToTypeID found on the first line of each part of the code. It states that whenever a user resets the foreground and background or sets either the foreground or background color, the character ID key to call those actions/events are Rset and setd respectively. The two character ID code will be used later in this tutorial.
    Note: Other actions or events could also contain the setd parameter although a different block of code is produced.

  11. Close the text editor.
Continue to ActionScript