Skip to main content
JJMack
Community Expert
Community Expert
Jun 26, 2015 5:38 PM UTC
Released

P: Scripting preventDefault event not working

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 is closed to new replies. Start a new post to keep the conversation going.

14 replies

JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Jan 22, 2016 1:19 AM UTC
Yes it is thanks.
Translate
JJMack
Legend
Jan 21, 2016 4:10 PM UTC
Hi John, This should be solved in the 2015.1.2 update released today: http://blogs.adobe.com/crawlspace/201...
Translate
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Dec 16, 2015 9:04 PM UTC
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
Translate
JJMack
Legend
Dec 16, 2015 4:38 PM UTC
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.
Translate
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Dec 15, 2015 9:55 PM UTC
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.
Translate
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Dec 11, 2015 10:02 PM UTC
not fixed
Translate
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Dec 2, 2015 12:06 AM UTC
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
Translate
JJMack
Legend
Dec 1, 2015 5:13 AM UTC
The issue with keydown should be solved by the CC 2015.1 update that was released today: https://blogs.adobe.com/photoshop/201...
Translate
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Aug 5, 2015 2:02 AM UTC
Non Numerical characters are not beeped and rejected...

Translate
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
Aug 5, 2015 12:17 AM UTC
Please unmark this as solved...
Translate
JJMack