2 Replies Latest reply on Sep 1, 2014 5:27 AM by creativejoan0425

    About UI dialog

    creativejoan0425 Level 1

      I have a UI dialog with a dropdownlist and a edit text box, when I choose 1, I want the text field change to one immediately, and when I type three in the text field I want the dropdownlist change to 3, is it possible?

       

      var w = new Window ("dialog");

      var myDropdown = w.add ("dropdownlist", undefined, ["1", "2", "3"]);

      myDropdown.selection = 0;

       

       

      var myText = w.add ("edittext", undefined, "");

             myText.characters = 20;

             myText.active = true;

      var myBottomGroup = w.add ("group");

            myBottomGroup.alignChildren = ["fill","fill"];

            myBottomGroup.orientation = "column";

            myBottomGroup.add ("button", undefined, "OK");

            myBottomGroup.add ("button", undefined, "Cancel");

       

       

      if(myDropdown.selection == 1){

          myText.text = "one";

      }

      if(myDropdown.selection == 2){

          myText.text = "two";

      }

      if(myDropdown.selection == 2){

          myText.text = "three";

      }

      if(myText.text == "one"){

          myDropdown.selection = 1;

      }

      if( myText.text == "two"){

         myDropdown.selection = 2;

      }

      if(myText.text == "three"){

         myDropdown.selection = 3 ;

      }

       

       

      var myWindow = w.show();

      if (myWindow == true){

         

          if(myDropdown.selection == 1){

          myText.text = "one";

      }

      if(myDropdown.selection == 2){

          myText.text = "two";

      }

      if(myDropdown.selection == 2){

          myText.text = "three";

      }

      if(myText.text == "one"){

          myDropdown.selection = 1;

      }

      if( myText.text == "two"){

         myDropdown.selection = 2;

      }

      if(myText.text == "three"){

         myDropdown.selection = 3 ;

      }

       

       

      }

        • 1. Re: About UI dialog
          drerol74 Level 2

          Hello Joan,

           

          try this:

           

          ...
          
          myDropdown.onChange = function() {
          
          switch (myDropdown.selection.index) {
              case 0 :
                myText.text = "one";
                break;
              case 1 :
                myText.text = "two";
                break;
              case 2 :
                myText.text = "three";  
            }
          }
          
          myText.onChanging = function() {
          
            switch (myText.text) {
              case "one" :
                myDropdown.selection = 0;
                break;
              case "two" :
                myDropdown.selection = 1;
                break;
              case "three" :
                myDropdown.selection = 2;
            }
          }
          
          var myWindow = w.show();
          
          ...
          

           

          Roland

          • 2. Re: About UI dialog
            creativejoan0425 Level 1

            Thx, it very helpful