15 Messages
•
238 Points
Mon, Nov 30, 2020 10:46 PM
Acknowledged
Photoshop: 'Edit Text' field 'enter key' behavior being overridden (JavaScript, Windows)
The enter key in the simplified test code below is not allowing users to create a new line within the edit text field (as expected). Instead, the modal is being submitted. The code works properly on OSX but not Windows.
I've mostly tried eventListener related solutions. So enterKey, onEnterKey, onChange, change, etc - then assigning them to different elements in the interface. Haven't been able to get those event listeners to fire, but if I could, would try event.preventDefault() or event.stopPropogation() as well. No luck yet.
var modal = new Window("dialog");
modal = addFilenamesPanel(modal)
/*
Commenting 'addSubmissionButtonsGroup' fixes the issue.
So maybe there is problematic a event listener or
propogation occurring within the submission buttons.
*/
modal = addSubmissionButtonsGroup(modal)
modal.show();
function addFilenamesPanel(modal) {
modal.filenamesPanel = modal.add(
"panel",undefined,"Filenames"
);
var panel = modal.filenamesPanel;
/*
'enterKeySignalsOnChange' fixes issue
on OSX but not Windows 10.
*/
panel.filenamesText = panel.add(
"EditText",undefined,"",{
multiline: true,
enterKeySignalsOnChange: true
}
)
panel.filenamesText.minimumSize = [400,200];
return modal
}
function addSubmissionButtonsGroup(modal) {
modal.submissionButtons = modal.add(
"group", undefined, "submit"
);
modal.submissionButtons.cancel = addButton(
modal.submissionButtons,"cancel",false
);
modal.submissionButtons.ok = addButton(
modal.submissionButtons,"ok",true
);
return modal
function addButton(group,buttonName,response) {
group.add(
"button", undefined, buttonName,
{name: buttonName}
)
group.addEventListener( "click", function() {
return response
});
return group
}
}

Problems
•
Updated
a month ago
• Edited
41
4
0
Helpful Widget
How can we improve?
Tags
photoshop
api
windows
Responses
Official Solution
JeffreyTranberry
Adobe Administrator
•
15.8K Messages
•
295K Points
2 months ago
Thanks. I've asked engineering to take a look.
Sr. Product Manager, Adobe Digital Imaging
0
lumigraphics
1K Messages
•
17.1K Points
2 months ago
Buttons already have an event listener, you don't add one. Use the built-in onClick() function.
0
zollie_barnes
15 Messages
•
238 Points
2 months ago
Might be narrowing in on the problem. The enter key unexpectedly fires a click event when no click occurs (but the enter button is pressed). Here's the modal with only the ok button in it.
It's also odd that the modal would close when no close() method has been called.
(edited)
2
0
lumigraphics
1K Messages
•
17.1K Points
2 months ago
Try this sample:
testWindow = new Window ('palette', 'test', undefined, {closeButton:true});
testWindow.orientation = 'column';
testWindow.alignChildren = ['fill', 'fill'];
testPanel = testWindow.add('panel', undefined, 'Test');
testPanel.orientation = 'column';
testPanel.alignChildren = ['fill', 'top'];
testPanel.margins = [10, 10, 10, 10];
testPanel.etxt = testPanel.add('edittext', undefined, 'Works ok here.', {multiline:true, wantReturn:true});
testPanel.etxt.preferredSize = [200, 100];
testPanel.btn = testPanel.add('button', undefined, 'Click Me');
testPanel.btn. function(){
testPanel.etxt.text = 'No problem';
}
testWindow.layout.layout(true);
testWindow.show();
(edited)
9
0