Photoshop CC 2015 changes to scripting

X there seems to be a big difference as to how ContactSheetII  UI works in CC 2015 and CC 2014 with some of the input fields it that because of the eventlistener code? The change seem to be in the panel. The CC 2014 version run in cc 2015 still seem to filter some of the numeric input fields not allow character be entered..

I use Mike Hale code for handling numeric input fields in several script and now that way does not work in CC 2015.   Your CC 2014 version of contacsheetII handles in CC 2015 some of your dialogs fields the way I want to.  However I do not know JavaScript only hack at it and I do not understand how your CC 2014 code works.

Could you please do me a favor a post a simple dialog that only allows numeric data to be entered into its input field that will work in CC 2015 and CC 2014.

I like the immediate feedback and not having to check if is not numeric and then have to putout a message and then re-display the dialog.  For that way I need to restructure my poor hacks.

Here the code Mike posted that no longer works in CC 2015  the keydown event handler is never triggered

function NumericEditKeyboardHandler (event) {

        var keyIsOK = KeyIsNumeric (event) || 

                      KeyIsDelete (event) || 

                      KeyIsLRArrow (event) ||

                      KeyIsTabEnterEscape (event);

        if (! keyIsOK) {

            //    Bad input: tell ScriptUI not to accept the keydown event

            event.preventDefault();

            /*    Notify user of invalid input: make sure NOT

                to put up an alert dialog or do anything which

                requires user interaction, because that

                interferes with preventing the ‘default’

                action for the keydown event */

        ; // alert (“Ack! bug in NumericEditKeyboardHandler: ” + e);

//    key identifier functions

function KeyIsNumeric ( event ) {

    return  ( event.keyName >= ‘0’ ) && ( event.keyName <= ‘9’ ) && ! KeyHasModifier ( event );

function KeyHasModifier ( event ) {

    return event.shiftKey || event.ctrlKey || event.altKey || event.metaKey;

function KeyIsDelete (event) {

    //    Shift-delete is ok

    return (event.keyName == ‘Backspace’) && ! (event.ctrlKey);

function KeyIsLRArrow (event) {

    return ((event.keyName == ‘Left’) || (event.keyName == ‘Right’)) && ! (event.altKey || event.metaKey);

function KeyIsTabEnterEscape (event) {

    return event.keyName == ‘Tab’ || event.keyName == ‘Enter’ || event.keyName == ‘Escape’;

function createDialog( ) {

    var dlg = new Window( ‘dialog’, ‘Example Dialog’ );

    dlg.maskSt = dlg.add( ‘edittext’, undefined, ” );

    dlg.maskSt.preferredSize.width = 40;

    dlg.maskSt.addEventListener (‘keydown’, NumericEditKeyboardHandler );

   dlg.btnPnl = dlg.add( ‘panel’, undefined, ‘Process’ );

   dlg.btnPnl.orientation = “row”;

   dlg.btnPnl.alignment = “right”;

   dlg.btnPnl.okBtn = dlg.btnPnl.add( ‘button’, undefined, ‘Ok’, { name:’ok’ });

   dlg.btnPnl.cancelBtn = dlg.btnPnl.add( ‘button’, undefined, ‘Cancel’, { name:’cancel’ });

function initializeDialog( w ) {

    w.maskSt.addEventListener (‘keydown’, NumericEditKeyboardHandler );

    w.maskSt.onChanging = function() {

                                    // range check if needed

                                        if( Number(this.text) < 0 || Number(this.text) > 100 ){

                                            alert(‘Out of range’);

                                            // handle however you like

                                            this.text = ”;

    w.btnPnl.okBtn.onClick = function ( ) { this.parent.parent.close( 1 ); };

    w.btnPnl.cancelBtn.onClick = function ( ) { this.parent.parent.close( 2 ); };

runDialog = function( w ) {

var win = createDialog();

initializeDialog( win );

Advertisements