Skip to main content
JJMack
Community Expert
Community Expert
June 26, 2015

P: Scripting preventDefault event not working

  • June 26, 2015
  • 14 replies
  • 610 views

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. function ( ) { this.parent.parent.close( 1 ); alert("OK"); };
w.btnPnl.cancelBtn. function ( ) { this.parent.parent.close( 2 ); alert("Cancel");};
};
runDialog = function( w ) {
return w.show( );
};
var win = createDialog();
initializeDialog( win );
runDialog( win );

This topic has been closed for replies.

14 replies

JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
January 22, 2016
Yes it is thanks.
JJMack
Legend
January 21, 2016
Hi John, This should be solved in the 2015.1.2 update released today: http://blogs.adobe.com/crawlspace/201...
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
December 16, 2015
Thank you

I believe that there may be I bug in "event.preventDefault()" still I do not see the keydown event in the script being triggered at all in CC 2015

function NumericEditKeyboardHandler (event) {
try {
alert("test input");

Adobe Photoshop Version: 2015.1.1 20151209.r.327 2015/12/09:23:59:59 CL 1055659 x64
Operating System: Windows 10 64-bit
Version: 10 or greater
JJMack
Legend
December 16, 2015
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.
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
December 15, 2015
Just install the latest update:
Adobe Photoshop Version: 2015.1.1 20151209.r.327 2015/12/09:23:59:59 CL 1055659 x64
Operating System: Windows 10 64-bit
Version: 10 or greate

The buts is still not fixed.
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
December 11, 2015
not fixed
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
December 2, 2015
That does not seem to be the case on my machine. And the new color defaults makes the input field just about invisible.

Here is a link to the simple script the above one seems to be corrupt from the paste???

http://www.mouseprints.net/old/dpr/MH...

One should not be able to enter non numeric data in the input field

Please mark the problem not solved
JJMack
Legend
December 1, 2015
The issue with keydown should be solved by the CC 2015.1 update that was released today: https://blogs.adobe.com/photoshop/201...
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
August 5, 2015
Non Numerical characters are not beeped and rejected...

JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
August 5, 2015
Please unmark this as solved...
JJMack