5 Replies Latest reply on Oct 5, 2015 10:23 PM by K159

    Dialog box stop.

    K159 Level 1
      #targetengine session;
      main();
      function main(){
          var w = new Window ("palette", "test");
          var btnSize = [0,0,50,65]; // Size of the buttons
          var row, i, j, buttons = {};
         
        
          var charArr = [[0xFF41, "alpha"], [0xFF42,"beta"], [0xFF47,"gamma"], [0xFF44,"delta"]];
          
          var p2 = w.add ("panel");
          row = p2.add ("group");
              
          var myClickHandler = function(ev)  
          {  
              var btn = ev.target,  
                    ps = btn.properties;  
              if( !ps.hasOwnProperty('idx') ) return;  
              w.preview.text = findCharacter (buttons[ps.idx].text) || '';
              w.showUnicode.text = buttons[ps.idx].text.length > 0 ? ('00' + w.preview.text.charCodeAt().toString(16).toUpperCase()).slice(-4) : '';
          };
          for( i=0 ; i<charArr.length ; i++ )  
          {
              buttons[i] = row.add("button", btnSize, String.fromCharCode(charArr[i][0]),{idx:i});
              buttons[i].graphics.font = ScriptUI.newFont ("Helvetica","" , 40);
              buttons[i].helpTip = ("0"+charArr[i][0].toString(16)).toUpperCase();
          }
          
      row.addEventListener('click', myClickHandler);
          
            w.preview = w.add ('edittext {justify: "center", preferredSize: [150, 150]}');
              w.preview.graphics.font =ScriptUI.newFont ("Letter Gothic Std", "Bold", 120);
            
            w.group = w.add ('group')
              w.entry = w.group.add ('edittext {active: true, preferredSize: [50, -1]}');
              w.showUnicode = w.group.add ('edittext {characters: 4, readonly: true}');
              w.help1 = w.group.add ('button {text: "@", preferredSize: [20, -1]}');
              w.help2 = w.group.add ('button {text: "@", preferredSize: [20, -1]}');
              w.ok = w.group.add ('button {text: "OK", visible: false, preferredSize: [1,-1]}');
            
            w.show();
        }
      function findCharacter (s) {
          switch (s) {
            case "a" : return "\u03B1"  // alpha
            case "b" : return "\u03B2"  // beta
            case "g" : return "\u03B3"  // gamma
            case "d" : return "\u03B4"  // delta
            default: return '';
          }
        }
      
      
      
      
      
      

       

       

       

       

       

       

      Clicking on the character button appears significantly below.

       

      But, dialog box will stop if button quickly click to continue.

       

      What is wrong?

       

      How can I prevent it?

       

      Thanks for help.