• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to press the apply button through the "enter" key on the keyboard?

Contributor ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

Hi everyone, how do I press the apply button through the "enter" key on the keyboard?

I know that for this to happen, the button will first have to be selected by a blue border. As shown in picture B of the figure below. Thank you.

Screenshot_1.jpg

var dlg = new Window ("dialog", "My dialog", [0,0,0,0]) 

dlg.size = [200,100] 

dlg.location = [600,260]  

var dlgborda = dlg.add('panel', [10,5,190,80], '');

var b1 = dlgborda.add("button", [0,0,0,0], "Cancela") 

       b1.location = [10, 12] 

       b1.size = [70, 25]

var b2 = dlgborda.add("button", [0,0,0,0], "Apply") 

b2.location = [90,12] 

b2.size = [70, 25]  

b1.onClick = function(){

dlg.close()

}

b2.onClick = function(){

dlg.close()

tp(); 

dlg.show() 

function tp(){ 

  alert("To apply") 

}

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , May 29, 2017 May 29, 2017

Hi Ps-Design!

I have researched right here in the forum and found in this script a few lines of code that can help you.

Script UI Strange behavior on keybord events.

I have not got experience with programming, but I did a little modification in your script:

var dlg = new Window ("dialog", "My dialog", [0,0,0,0])   

dlg.size = [200,100]   

dlg.location = [600,260]    

var dlgborda = dlg.add('panel', [10,5,190,80], ''); 

var btn_cancelar = dlgborda.add("button", [0,0,0,0], "Cancela")   

       btn

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

Ps-Design​,

eg you can use the property "active"

var b2 = dlgborda.add("button", [0,0,0,0], "Apply")   

b2.location = [90,12]   

b2.size = [70, 25]

b2.active = true;

Have fun

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

pixxxel schubser

Right! The button was actually selected, the next step will be to add a keyboard shortcut to make the button work by pressing the enter key. How to proceed?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

This will works when running with target ESTK but not with target PS or Illu, sorry

var b2 = dlgborda.add("button", [0,0,0,0], "Apply")   

b2.location = [90,12]   

b2.size = [70, 25]

//b2.active = true;

b2.shortcutKey  = "1"; // use [Alt]+[1]

b2.onShortcutKey = b2.onClick;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

pixxxelschubser escreveu

 

This will works when running with target ESTK but not with target PS or Illu, sorry

var b2 = dlgborda.add("button", [0,0,0,0], "Apply")     b2.location = [90,12]     b2.size = [70, 25] //b2.active = true; b2.shortcutKey  = "1"; // use [Alt]+[1] b2.onShortcutKey = b2.onClick; 
 

Hi .... I tested here in Photoshop and it did not work, but I'm glad for your attention and willingness to help me! Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

Hi Ps-Design!

I have researched right here in the forum and found in this script a few lines of code that can help you.

Script UI Strange behavior on keybord events.

I have not got experience with programming, but I did a little modification in your script:

var dlg = new Window ("dialog", "My dialog", [0,0,0,0])   

dlg.size = [200,100]   

dlg.location = [600,260]    

var dlgborda = dlg.add('panel', [10,5,190,80], ''); 

var btn_cancelar = dlgborda.add("button", [0,0,0,0], "Cancela")   

       btn_cancelar.location = [10, 12]   

       btn_cancelar.size = [70, 25] 

var btn_enter = dlgborda.add("button", [0,0,0,0], "Apply")   

       btn_enter.location = [90,12]   

       btn_enter.size = [70, 25]

       btn_enter.active = true;

 

 

//Cancelar

btn_cancelar.onClick = function(){  

dlg.close() 

 

//Apply

function press_enter() {

dlg.close ()

comando();

}

 

 

dlg.addEventListener('keydown', function(event) {

     if (event.keyName == 'Enter') {

     press_enter ()}

})

 

dlg.show()   

 

// My Script!

function comando(){   

  alert("To apply")   

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

Hi smithcgl9043167 Very good guy saw, how wonderful! It worked perfectly well. Thank you very much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2017 May 29, 2017

Copy link to clipboard

Copied

LATEST

Ps-Design

Please read my last posting again:

"… but not with target PS or Illu, sorry …"

For Enter and ESC you can also use the dlg.defaultElement

smithcgl9043167​,

good finding.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines