Script UI Strange behavior on keybord events.


good day.

for example, write script:

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

var user_dialog =

"dialog{text:'up/down , space control',bounds:[370,370,970,555],\

        \

        msgpnl0: panel {text:'press up/down or left/right make 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\" 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 start in extendscript toolkit cc , link script extendscript toolkit cc of work correctly. 1 bug - when press "space" after mouse switching chekbox, , don't understand why.

 

when start in extendscript toolkit cc , link script adobe photoshop cc 2015, nothing work corectly. switching cursor keys work after switching radiobutton mouse. switching "space" work after switching chekbox mouse. when press "enter" - nothing doing.

 

when start in extendscript toolkit cc , link script adobe photoshop cc, see bugs, saw in cc2015 , more: switching keybord position 4 position 1 "down" key not work , switching keybord position 1 position 4 "up" key not work.

 

i don't understand mistake , how change code correctly working script.

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

 

 

when start in extendscript toolkit cc , link script extendscript toolkit cc of work correctly. 1 bug - when press "space" after mouse switching checkbox, , don't understand why.

i understand why, don't understand how fix it.

 

when press "space" after mouse switching checkbox, pressed twice. first keybord event, second default element after focusing on checkbox after mouse press. if press "tab" , switch focus next element , after press "space" see 2 events: first - checkbox switching, second - radiobuttom switching or "enter" pressing.



More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop