3 Replies Latest reply on Feb 16, 2011 5:24 AM by Pablo Souza

    Disable/enable window close button?

    RandomReado Level 1

      I have a new Window() open and I want to disable the close button when the window has already been opened. Does anyone know how to do this in Flex?

        • 1. Re: Disable/enable window close button?
          Pablo Souza Level 3

          Hello!

           

          What kind of Flex control are you using? Is it a TitleWindow?

           

          Regards,

          Pablo Souza

          http://rectius.com.br/blog

          • 2. Re: Disable/enable window close button?
            RandomReado Level 1

            I'm using the Window class. By close button I mean the red X icon in the Windows title bar.

            • 3. Re: Disable/enable window close button?
              Pablo Souza Level 3

              Ok I got, it's an AIR app.

               

              You can listen to event Closing and preventDefault on it. Check this:

               

              <?xml version="1.0" encoding="utf-8"?>
              <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                     xmlns:s="library://ns.adobe.com/flex/spark" 
                                     xmlns:mx="library://ns.adobe.com/flex/mx"
                                     closing="closingHandler(event)">
               <fx:Script>
                          <![CDATA[
                              protected function closingHandler(event:Event):void
                              {
                                  if(!forceClose.selected)
                                          event.preventDefault();
                              }
                          ]]>
               </fx:Script>
               
               <s:CheckBox id="forceClose" label="Force close" />
               
              </s:WindowedApplication>
              

               

              Regards,

              Pablo Souza