Skip to main content
Inspiring
March 12, 2012
Answered

Keybinding to custom dialog options?

  • March 12, 2012
  • 1 reply
  • 1655 views

Is there a way to bind a key to a certain task when a dialog box is open?  For example, if I have a dialog box that comes up with multiple check-boxes and I want to check or un-check the box next to "trim" by hitting the T key, can this be done?  Thanks for any help!

dgolberg

This topic has been closed for replies.
Correct answer Paul Riggott

Yes it's possible but only with Photoshop CS4 as events handlers are bust in CS5.

var w = new Window('dialog','test checkbox');

w.cb1 = w.add('checkbox',undefined,'Trim');

w.bu1 = w.add('button',undefined,'cancel');

w.cb1.value=true;

w.addEventListener ('keydown', IsT);

function IsT (event) {

if  ((event.keyName =='t') || (event.keyName == 'T')) w.cb1.value=!w.cb1.value;

}

w.show();

1 reply

Paul Riggott
Paul RiggottCorrect answer
Inspiring
March 12, 2012

Yes it's possible but only with Photoshop CS4 as events handlers are bust in CS5.

var w = new Window('dialog','test checkbox');

w.cb1 = w.add('checkbox',undefined,'Trim');

w.bu1 = w.add('button',undefined,'cancel');

w.cb1.value=true;

w.addEventListener ('keydown', IsT);

function IsT (event) {

if  ((event.keyName =='t') || (event.keyName == 'T')) w.cb1.value=!w.cb1.value;

}

w.show();

Inspiring
March 12, 2012

Being mac I've never tried but Paul couldn't you use shortcutKey in windows? Rather that adding an event I have no idea…

Paul Riggott
Inspiring
March 12, 2012

Can't seem to get that working either Mark, maybe I have the syntax wrong?