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

Script UI Strange behavior on keybord events.

Community Beginner ,
Sep 13, 2016 Sep 13, 2016

Copy link to clipboard

Copied

Good Day.

For example, I write this script:

-----------------------------------------------------------------------------------------------------------------------------------------------

var user_dialog =

"dialog{text:'Up/Down and Space control',bounds:[370,370,970,555],\

        \

        msgPnl0: Panel {text:'press Up/Down or Left/Right to make a choise', bounds:[15,20,385,170], \

        rb_rs1: RadioButton {text:'Position 1', alignment:'left ', bounds:[15,15,240,35], value:true},\

        rb_rs2: RadioButton {text:'Position 2', alignment:'left ', bounds:[15,45,240,65]},\

        rb_rs3: RadioButton {text:'Position 3', alignment:'left ', bounds:[15,75,240,95]},\

        rb_rs4: RadioButton {text:'Position 4', alignment:'left ', bounds:[15,105,240,125]},\

        },\

        \

         cb1: Checkbox {text:'press \"space\" to switch', alignment:'left ', bounds:[400,75,580,100],value:false}, \

         \

        button1: Button{bounds:[400,20,580,60] , text:'Enter' },\

        }";

       

var test_dialog = new Window (user_dialog)

function read_choise () {

    if (test_dialog.msgPnl0.rb_rs1.value == true) {return 1}

    if (test_dialog.msgPnl0.rb_rs2.value == true) {return 2}

    if (test_dialog.msgPnl0.rb_rs3.value == true) {return 3}

    if (test_dialog.msgPnl0.rb_rs4.value == true) {return 4}

    }

function write_choise (position) {

    if (position == 1) {test_dialog.msgPnl0.rb_rs1.value = true}

    if (position == 2) {test_dialog.msgPnl0.rb_rs2.value = true}

    if (position == 3) {test_dialog.msgPnl0.rb_rs3.value = true}

    if (position == 4) {test_dialog.msgPnl0.rb_rs4.value = true}

    }

function next_choise() {

    write_choise ((read_choise ())%4+1)

    }

function previous_choise() {

     write_choise ((read_choise ()+2)%4+1)

     }

function press_space() {

     if (test_dialog.cb1.value == true) { test_dialog.cb1.value = false}

     else { test_dialog.cb1.value = true}

     }

function press_enter() {

     test_dialog.close ()

     alert ('Position '+read_choise ()+', \"space\" key chekbox = ' +  test_dialog.cb1.value , 'Your Choise')

     }

test_dialog.button1.onClick = function () {

     press_enter ()

     }

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

         if ((event.keyName == 'Up') || (event.keyName == 'Left')) {

             previous_choise()

             }

         if ((event.keyName == 'Down') || (event.keyName == 'Right')) {

             next_choise()

             }

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

             press_space()

             }

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

             press_enter ()

             }

         })

test_dialog.show()

---------------------------------------------------------------------------------------------------------------------------------------------------------------

When I start it in ExtendScript Toolkit CC and link this script with ExtendScript Toolkit CC most of all work correctly. Only one bug - when I press "space" after mouse switching chekbox, and I don't understand why.

When I start it in ExtendScript Toolkit CC and link this script with Adobe Photoshop CC 2015, nothing work corectly. Switching by cursor keys work only after switching radiobutton by mouse. Switching by "space" work only after switching chekbox by mouse. When I press "Enter" - nothing doing.

When I start it in ExtendScript Toolkit CC and link this script with Adobe Photoshop CC, I see all bugs, which I saw in CC2015 and more: switching by keybord from position 4 to position 1 by "down" key not work and switching by keybord from position 1 to position 4 by "up" key not work.

I don't understand where is my mistake and how change my code for correctly working script.

TOPICS
Actions and scripting

Views

378

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
Adobe
Community Beginner ,
Sep 13, 2016 Sep 13, 2016

Copy link to clipboard

Copied

LATEST

alex rezvov написал(а):

When I start it in ExtendScript Toolkit CC and link this script with ExtendScript Toolkit CC most of all work correctly. Only one bug - when I press "space" after mouse switching checkbox, and I don't understand why.

I understand why, but don't understand how fix it.

When I press "space" after mouse switching checkbox, it pressed twice. First as keybord event, second as default element after focusing on checkbox after mouse press. If I press "Tab" and switch focus to next element and after that press "space" I see two events: first - checkbox switching, second - radiobuttom switching or "Enter" pressing.

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