4 Replies Latest reply on Aug 20, 2006 4:13 PM by Opera Rat

    Close the box

    Opera Rat Level 1
      I think I have everything but one function working on my dropdownmenus and that one little thing is probably going to mean a major change. If I click on the menu header the dropdown opens, if I choose something it disappears, or if I let go of the cursor outside the dropdown it closes. That is all great. But what if I open the drop down by clicking on the menu header and decide there is nothing there that I want. How do I get it to close? If I click anywhere else on the stage it stays open. When I click on the header I set a parameter to true and when I click on something it turns to false. This is what is opening and closing the menu. How do I get it to false if I click on the stage or click the menu header again. I'm trying to get dropdowns like most programs (Word, Director), except that I want mine in the middle of my stage and done with sprites. How do these menus work!!!! Once you click on a director menu header the menu stays open and if you move the mouse over the next menu that one opens and the one you were on closes. Isn't there a tutorial somewhere that shows one how to the these standard dropdown menus?
        • 1. Re: Close the box
          Level 7
          To deal with the part about opening the next menu if you move the mouse
          over while a menu is open, I would do it like this. Set a global
          variable (I named it gMenuOpen) whenever the menu is open, and set it
          back when it is closed. Then, on your menu sprite, tell it to open if
          the global is set:

          global gMenuOpen

          on mouseEnter me
          if(gMenuOpen) then
          --your code here that does the actual opening
          end if

          Somewhere in your existing code, when you actually open the menu, just
          remember to set gMenuOpen=1. In your code, wherever you close the menu,
          set gMenuOpen=0.

          In order to get the menu to close then you click on the stage, make a
          MOVIE script that looks like this:

          global gMenuOpen

          on mouseUp me
          if(gMenuOpen) then
          --your code here that closes the menu
          end if

          Since it is a movie script, it will run every time you click anywhere
          and that click has not been trapped by another sprite. I mean, if you
          click on a sprite that has a mouseUp script, then this handler will not
          run. But if you just click on the stage, or on a sprite with no mouseUp
          handler, then it will run. If you want this to run even if you click on
          a sprite that has a mouseUp handler, then add the word 'pass' to the end
          of that sprite's mouseUp... like this:

          on mouseUp me
          --your code that is on the sprite

          Then it will pass the mouseUp on to the stage's movie script and it will
          close the menu.
          • 2. Re: Close the box
            Opera Rat Level 1
            YES!!! You did it. Thank you so much. I had the global variable in there to close the menu from one of the choices, I just had to add it in a movie script. And the menu next to it opens if I move from the open menu to another menu header. BUT...the previous menu stays open. So now two menus are open. I can't use a mouseLeave event because that would close the menu when I try to move to a choice beneath the menu. Do you have one more wise suggestion for me, please? One that would close the menu after another opens.
            • 3. Re: Close the box
              Level 7
              I don't know how you have your code setup, so I'll just throw this out
              there in hopes that it helps. If I were doing this, I would have a
              handler to open a menu and a handler to close it on the sprites that are
              responsible for the menu.

              on openMenu me
              --your code here to open the menu

              on closeMenu me
              --your code here to close the menu

              That sendAllSprites line in the openMenu() handler will automatically
              close any menu before opening the new one. If you do not have a
              dedicated handler to open the menu, you can just create put the
              sendAllSprites in your code just before the point where a menu gets
              • 4. Re: Close the box
                Opera Rat Level 1
                10 x a goole THANK YOU. It works perfectly. I feel my headache fading away...