Photoshop CC 2015: Scripting preventDefault event not working

  • 2
  • Problem
  • Updated 2 years ago
  • Solved
  • (Edited)
Photoshop CC 2015 scripting keydown event not working

This Mike Hale script works prior to CC 2015

function NumericEditKeyboardHandler (event) {
try {
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 */
app.beep();
}
}
catch (e) {
; // alert ("Ack! bug in NumericEditKeyboardHandler: " + e);
}
}
// key identifier functions
function KeyIsNumeric ( event ) {
return ( event.keyName >= '0' ) && ( event.keyName < 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 ); alert("OK"); };
w.btnPnl.cancelBtn.onClick = function ( ) { this.parent.parent.close( 2 ); alert("Cancel");};
};
runDialog = function( w ) {
return w.show( );
};
var win = createDialog();
initializeDialog( win );
runDialog( win );
Photo of John McAssey

John McAssey

  • 191 Posts
  • 7 Reply Likes

Posted 3 years ago

  • 2
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13789 Posts
  • 1619 Reply Likes
Official Response
The issue with keydown should be solved by the CC 2015.1 update that was released today: https://blogs.adobe.com/photoshop/201...
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13789 Posts
  • 1619 Reply Likes
Official Response
Hi John, I'm reviewing some JS bugs with QE. The keydown bug is fixed, the problem is the preventDefault bug is not fixed. Hoping to get the preventDefault issue addressed in the next update.
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13789 Posts
  • 1619 Reply Likes
Official Response
Hi John, This should be solved in the 2015.1.2 update released today: http://blogs.adobe.com/crawlspace/201...