Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Window autoChild not getting destroyed - show multiple buttons

    Browser: Firefox 3.6.8
    SmartClient 7.0RC2

    We created a window using autochild concept.
    When we reuse (instantiating again with same ID) the window next time we see two buttons and header moves to the bottom of the window.
    isc.defineClass("MyWindowClass","MyWindow");

    isc.MyWindowClass.addProperties({

    saveDefaults: {
    _constructor: isc.IButton,
    title: "Save",
    autoFit: true,
    click: function() {
    ....
    }
    },

    discardDefaults: {
    _constructor: isc.IButton,
    title: "Discard",
    autoFit: true,
    click: function() {
    ..
    }
    },
    initWidget: function() {
    this.Super("initWidget", arguments);
    this.addAutoChild("save");
    this.addAutoChild("discard");
    }

    });

    function openMyWindow () {
    isc.MyWindowClass.create({
    ID: "myWindowInstance"
    });

    myWindowInstance.show();
    }

    function closeWindow() {

    myWindowInstance.destroy();
    }
    //create first time
    openMyWindow();

    //destroy first time
    closeWindow();

    //create second time
    openMyWindow();
    //The reason we are reusing the window is so that we change its header or labels....

    #2
    There's no problem in this part of the code. Keep looking and let us know when you find out what's wrong.

    Comment


      #3
      Even in this code the header and close buttons are coming at the bottom.
      Can you suggest why is this happening!

      Comment


        #4
        Rewritten adding the buttons to a separate layout and making a modal window but the issue persists....

        isc.defineClass("MyWindowClass","MyWindow");

        isc.MyWindowClass.addProperties({
        title: "My Window",
        width:440,
        height:260,
        autoCenter: true,
        isModal: true,
        showModalMask: true,
        autoDraw:false,
        myLayoutDefaults: {
        _constructor: isc.HLayout
        },
        saveDefaults: {
        _constructor: isc.IButton,
        autoParent: "myLayout",
        title: "Save",
        autoFit: true,
        click: function() {

        }
        },

        discardDefaults: {
        _constructor: isc.IButton,
        autoParent: "myLayout",
        title: "Discard",
        autoFit: true,
        click: function() {

        }
        },

        initWidget: function() {
        this.Super("initWidget", arguments);

        this.addAutoChild("myLayout");
        this.addAutoChild("save");
        this.addAutoChild("discard");

        }

        });

        function openMyWindow () {
        isc.MyWindowClass.create({
        ID: "myWindowInstance"
        });

        myWindowInstance.show();
        alert("hi");
        }

        function closeWindow() {
        myWindowInstance.markForDestroy();
        myWindowInstance.destroy();
        alert("bye");
        }
        //create first time
        openMyWindow();

        //destroy first time
        closeWindow();

        //create second time
        openMyWindow();
        //The reason we are reusing the window is so that we change its header or labels....
        closeWindow();

        openMyWindow();

        Comment


          #5
          Creating reusable windows has always been a problem.
          Each time the headers/window title and close and minimize buttons move to the bottom of the window which is unexplanable.
          Help!

          Comment


            #6
            No mystery here - if you just call addAutoChild(), you're going to be adding after all the other widgets. If you want to add at a specific position, use createAutoChild(), then addMember specifying a position.

            Comment


              #7
              The header of first instance do not get destroyed even if we destroy/markForDestroy it. every other child and member gets destroyed but not the header....that is why it comes in the bottom.
              Next time the header comes to the bottom.
              Tell us a solution for destroying the header too!!!!

              Comment


                #8
                What header? The built-in Window header is definitely destroyed when you call destroy.

                If you've added your own header, and it's not a child or peer, you need to destroy it manually. But you do not appear to have a reason to create a separate header that is not a child.

                Comment


                  #9
                  I have attached two images of window
                  First time it comes just fine.
                  Second time the header/title comes at the bottom along with minimize and close button.

                  Let me reiterate, this happens if we create same instance again for a window created out of a custom window class.
                  Attached Files

                  Comment


                    #10
                    You've already been told what you are probably doing wrong (see post 6). If you believe your code is already correct, post a complete, minimal, ready-to-run testcase.

                    Comment


                      #11
                      Adding the code again..here the title and other buttons are coming after save and discard button...I will post another code in a while with first window with expected layout and second with title and maximize minimize buttons at the bottom of the window.


                      isc.defineClass("MyWindowClass","Window");

                      isc.MyWindowClass.addProperties({
                      title: "My Window",
                      width:440,
                      height:260,
                      autoCenter: true,
                      isModal: true,
                      showModalMask: true,
                      autoDraw:false,
                      myLayoutDefaults: {
                      _constructor: isc.HLayout
                      },
                      saveDefaults: {
                      _constructor: isc.IButton,
                      autoParent: "myLayout",
                      title: "Save",
                      autoFit: true,
                      click: function() {

                      }
                      },

                      discardDefaults: {
                      _constructor: isc.IButton,
                      autoParent: "myLayout",
                      title: "Discard",
                      autoFit: true,
                      click: function() {

                      }
                      },

                      initWidget: function() {
                      this.Super("initWidget", arguments);

                      this.addAutoChild("myLayout");
                      this.addAutoChild("save");
                      this.addAutoChild("discard");

                      }

                      });

                      function openMyWindow () {
                      isc.MyWindowClass.create({
                      ID: "myWindowInstance"
                      });

                      myWindowInstance.show();
                      alert("hi");
                      }

                      function closeWindow() {
                      myWindowInstance.markForDestroy();
                      myWindowInstance.destroy();
                      alert("bye");
                      }
                      //create first time
                      openMyWindow();

                      //destroy first time
                      closeWindow();

                      //create second time
                      openMyWindow();
                      //The reason we are reusing the window is so that we change its header or labels....
                      closeWindow();

                      openMyWindow();

                      Comment


                        #12
                        Right, so again, need to look really hard at what we told you in update #6.

                        Here it is again:

                        No mystery here - if you just call addAutoChild(), you're going to be adding after all the other widgets. If you want to add at a specific position, use createAutoChild(), then addMember specifying a position.
                        We've told you different APIs to call, but you've not made any changes to your code.

                        Comment


                          #13
                          I did the changes you told by using createAutoChild for save and discard buttons and added them to position 0, 1
                          Now the buttons are not visible at all

                          isc.defineClass("MyWindowClass","Window");

                          isc.MyWindowClass.addProperties({
                          title: "My Window",
                          width:440,
                          height:260,
                          autoCenter: true,
                          isModal: true,
                          showModalMask: true,
                          saveBtnDefaults: {
                          _constructor: isc.IButton,
                          title: "Save"
                          },
                          discardBtnDefaults: {
                          _constructor: isc.IButton,
                          title: "Discard"
                          },

                          initWidget: function() {
                          this.Super("initWidget", arguments);
                          this.addMember(0,this.createAutoChild("saveBtn"));
                          this.addMember(1,this.createAutoChild("discardBtn"));



                          }

                          });

                          function openMyWindow () {
                          isc.MyWindowClass.create({
                          ID: "myWindowInstance"
                          });

                          myWindowInstance.show();
                          alert("hi");
                          }

                          function openMyWindow2 () {
                          isc.MyWindowClass.create({
                          ID: "myWindowInstance2"
                          });

                          myWindowInstance2.show();
                          alert("hi2");
                          }

                          function closeWindow() {
                          myWindowInstance.markForDestroy();
                          myWindowInstance.destroy();
                          alert("bye");
                          }

                          function closeWindow2() {
                          myWindowInstance2.markForDestroy();
                          myWindowInstance2.destroy();
                          alert("bye2");
                          }

                          //create first time
                          openMyWindow();
                          openMyWindow2();
                          //destroy first time
                          closeWindow();
                          closeWindow2();

                          //create second time
                          openMyWindow();
                          //The reason we are reusing the window is so that we change its header or labels....
                          closeWindow();

                          openMyWindow();

                          Comment


                            #14
                            Wrong arguments to addMember() (member comes first) and there are warning in your Developer Console telling you that you have made this mistake.

                            Please only involve Support once you've run through elementary steps like checking your Developer Console.

                            Comment


                              #15
                              I have added the save button and discard button using addMember at a position and created using createAutoChild. See the attachment which has the same issue ....! Do suggest

                              isc.defineClass("MyWindowClass","Window");

                              isc.MyWindowClass.addProperties({
                              title: "My Window",
                              width:440,
                              height:260,
                              autoCenter: true,
                              isModal: true,
                              showModalMask: true,
                              saveBtnDefaults: {
                              _constructor: isc.IButton,
                              title: "Save"
                              },
                              discardBtnDefaults: {
                              _constructor: isc.IButton,
                              title: "Discard"
                              },

                              initWidget: function() {
                              this.Super("initWidget", arguments);
                              this.addMember(this.createAutoChild("saveBtn"),0);
                              this.addMember(this.createAutoChild("discardBtn"),1);



                              }

                              });

                              function openMyWindow () {
                              isc.MyWindowClass.create({
                              ID: "myWindowInstance"
                              });

                              myWindowInstance.show();
                              alert("hi");
                              }

                              function openMyWindow2 () {
                              isc.MyWindowClass.create({
                              ID: "myWindowInstance2"
                              });

                              myWindowInstance2.show();
                              alert("hi2");
                              }

                              function closeWindow() {
                              myWindowInstance.markForDestroy();
                              myWindowInstance.destroy();
                              alert("bye");
                              }

                              function closeWindow2() {
                              myWindowInstance2.markForDestroy();
                              myWindowInstance2.destroy();
                              alert("bye2");
                              }

                              //create first time
                              openMyWindow();
                              openMyWindow2();
                              //destroy first time
                              closeWindow();
                              closeWindow2();

                              //create second time
                              openMyWindow();
                              //The reason we are reusing the window is so that we change its header or labels....
                              closeWindow();

                              openMyWindow();
                              Attached Files

                              Comment

                              Working...
                              X