4 Replies Latest reply on Jul 25, 2009 2:10 AM by Liphou

    DropDownList

    Liphou Level 1

      Hello,

       


      would I like added a group but don't I arrive there and for the Panel (User Interface Tools page 84)

       

      Thank you

       

      Programme de traduction

       

      Bonjour,

       

      je voudrais rajouté un groupe mais je n'y arrive pas et pour le panel?

       

      Merci

       

      res =
      "dialog {  \
      whichInfo: DropDownList { alignment:'left' }, \
      allGroups: Panel { orientation:'stack', alignChildren: 'right',\
      info: Group { orientation: 'column', \
      name: Group { orientation: 'row', \
      s: StaticText { text:'Name:' }, \
      e: EditText { characters: 30 } \
      } \
      }, \
      workInfo: Group { orientation: 'column', \
      name: Group { orientation: 'row', \
      s: StaticText { text:'Test:' }, \
      e: EditText { characters: 30 } \
      } \
      }, \
      workInfo: Group { orientation: 'column', \
      name: Group { orientation: 'row', \
      s: StaticText { text:'Company name:' }, \
      e: EditText { characters: 30 } \
      } \
      }, \
      },\
      buttons: Group { orientation: 'row', alignment: 'right', \
      okBtn: Button { text:'OK', properties:{name:'ok'} }, \
      cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \
      } \
      }";
      win = new Window (res);

       

      win.whichInfo.onChange = function () {
          alert(this.item);
          if (this.selection != null) {
              for (var g = 0; g < this.items.length; g++)
                  this.items[g].group.visible = false; //hide all other groups
          this.selection.group.visible = true;//show this group
      }
      }
      var item = win.whichInfo.add ('item', 'Personal Info');
      //item = win.whichInfo.add ('item', 'Test');
      item.group = win.allGroups.info;
      item = win.whichInfo.add ('item', 'Work Info');

       

      //item = win.whichInfo.add ('item', 'Test');
      item.group = win.allGroups.workInfo;
      win.whichInfo.selection = win.whichInfo.items[0];
      win.center();
      win.show();
      //alert(e);

        • 1. Re: DropDownList
          [Jongware] Most Valuable Participant

          It uses the name 'workGroup' twice. All object names should be unique.

          • 2. Re: DropDownList
            Liphou Level 1

            Thank you, excuse me, I beginning, can you be one can more precise with the object

            Philippe

            • 3. Re: DropDownList
              [Jongware] Most Valuable Participant

              Ha -- I'm sorry, I meant it uses the name workInfo twice.

               

              It works like this: the res ("Resource") string is divided into blocks using the {curly braces}. Each block is added as a new ScriptUI object, and the parameters are set with the commands that follow inbetween braces. You need to assign a name to each ScriptUI element so you can use it later on in the script -- your sample does that below, with the "win.whichInfo" lines. There you can see that JavaScript has added the string info as variable names.

              Now the string resource contains two objects with the same name: "workInfo". It is not a real error, because in JavaScript you may assign a new value to a variable at any time (apparently, even in the middle of defining a resource). But that also means you don't have a reliable pointer to one of the objects anymore!

               

              Some indentation thrown in shows the object grouping. You can see the "workInfo" used twice, on the same level. If you change one of the names to something else, the script will work -- but you have to change the right instance of "workInfo" in the rest of the script as well.

               

              dialog { \
                  whichInfo: DropDownList { \
                      alignment:'left' \
                  }, \
                  allGroups: Panel { \
                      orientation:'stack', alignChildren: 'right', \
                      info: Group { \
                          orientation: 'column', \
                          name: Group { \
                              orientation: 'row', \
                              s: StaticText { text:'Name:' }, \
                              e: EditText { characters: 30 } \
                          } \
                      }, \
                      workInfo: Group { \
                          orientation: 'column', \
                          name: Group { \
                              orientation: 'row', \
                              s: StaticText { text:'Test:' }, \
                              e: EditText { characters: 30 } \
                          } \
                      }, \
                      workInfo: Group \
                      { \
                          orientation: 'column', \
                          name: Group { \
                              orientation: 'row', \
                              s: StaticText { text:'Company name:' }, \
                              e: EditText { characters: 30 } \
                          } \
                      }, \
                  }, \
                  buttons: Group \
                  { \
                      orientation: 'row', alignment: 'right', \
                      okBtn: Button { text:'OK', properties:{name:'ok'} }, \
                      cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \
                  } \
              }";
              
              • 4. Re: DropDownList
                Liphou Level 1

                Thank you, did I understand the object of the group, I added of the “Checkbox” to the group “test2” how to make for aligned on the left? (Translating program)

                 

                res =
                    "dialog {  \
                        whichInfo: DropDownList { \
                            alignment:'left' \
                        }, \
                        allGroups: Panel { text:  'Test Bout', \
                            orientation:'stack', alignChildren: 'right',\
                            info: Group { \
                                orientation: 'column', \
                                name: Group { \
                                    orientation: 'row', \
                                    s: StaticText { text:'Name:' }, \
                                    e: EditText { characters: 30 } \
                                    } \
                                }, \
                            test: Group { \
                                orientation: 'column', \
                                name: Group { \
                                    orientation: 'row', \
                                    s: StaticText { text:'Test:' }, \
                                    e: EditText { characters: 30 } \
                                } \
                            }, \
                            test2: Group { \
                                orientation: 'column', \
                                name: Group { \
                                    orientation: 'row', \
                                    s: StaticText { text:'Test Suite:' }, \
                                    e: EditText { characters: 30 } \
                                        phBout: Checkbox {text:'Checkbox test'}  \
                                        phBout2: Checkbox {text:'Checkbox test'}\
                                        phDisabled: Checkbox {text:'Disabled'}\
                                        }\
                            }, \
                        workInfo: Group { \
                            orientation: 'column', \
                            name: Group { \
                                orientation: 'row', \
                                s: StaticText { text:'Company name:' }, \
                                e: EditText { characters: 30 } \
                            } \
                        }, \
                    },\
                    buttons: Group \
                        { \
                            orientation: 'row', alignment: 'right', \
                            okBtn: Button { text:'OK', properties:{name:'ok'} }, \
                            cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \
                        } \
                    }";
                win = new Window (res);

                win.whichInfo.onChange = function () {
                    //alert(this.item);
                    if (this.selection != null) {
                        for (var g = 0; g < this.items.length; g++)
                            this.items[g].group.visible = false; //hide all other groups
                    this.selection.group.visible = true;//show this group
                }

                }
                var item = win.whichInfo.add ('item', 'Personal Info');
                item.group = win.allGroups.info;
                item = win.whichInfo.add ('item', 'Work Info');
                item.group = win.allGroups.workInfo;
                item = win.whichInfo.add ('item', 'Merci');
                item.group = win.allGroups.test;
                item = win.whichInfo.add ('item', 'Plus');
                item.group = win.allGroups.test2;
                win.whichInfo.selection = win.whichInfo.items[0];
                win.center();
                win.show();

                It is possible to reduce this part of the code:

                 

                var item = win.whichInfo.add ('item', 'Personal Info');
                item.group = win.allGroups.info;
                item = win.whichInfo.add ('item', 'Work Info');
                item.group = win.allGroups.workInfo;
                item = win.whichInfo.add ('item', 'Merci');
                item.group = win.allGroups.test;
                item = win.whichInfo.add ('item', 'Plus');
                item.group = win.allGroups.test2;