7 Replies Latest reply on Jul 23, 2013 8:26 PM by hehiha

    Modal dialog extension


      I am building a hybrid extension that uses flash for the UI.  The extension is a modal dialog that has a Ok button, that when pressed, closes the dialog and sends an event to the plugin that makes changes to the current document.


      The problem I am running into is that I simply can't get the dialog to close.  The plugin is getting the event and the artwork is modified, but the changes don't update (to the screen) until the dialog goes away.  I have tried a dozen different ways to close the dialog.  It seems that If I dispatch a csxs event before or after a close(), the dialog won't actually close.


      One thing I tried was to catch the CSExtension.close event.  This is supposed to be called after the extension closes.  If I press the Escape key, the dialog closes, this event is fired and I can dispatch my event and everything works correctly.  But if I click my Ok button, the dialog doesn't close, and I get the same problem as before.


      Here is my okClicked function:


      private function okClicked():void


        // create the event here







      Other things I have tried:


      • adding an Event.EXISTING listener
      • adding a NativeApplication.nativeApplication Event.EXISTING listener
      • force closing the window by dispatching Event.EXISTING events, nativeWindow.close(), NativeApplication.nativeApplication.exit(), etc
      • dispatching Keyboard.ESCAPE key up event (to simulate the user pressing the Esc key)


      Dispatching a csxs event during any of these will result in the dialog not closing.


      Any suggestions?

        • 1. Re: Modal dialog extension
          Harbs. Level 6

          What app is this with?



          • 2. Re: Modal dialog extension
            T.Nelson Level 1

            Illustrator, CS6

            • 3. Re: Modal dialog extension
              T.Nelson Level 1

              I figured out part of the problem.


              Our plugin shows a progress bar (AIUser->UpdateProgress()) due to the length of time it takes to modify the artwork.  The progress bar is shown before the extension has a chance to close.  When this happens, the extension can't close.  When I comment out the UpdateProgress code, the artwork is modified and the extension closes just fine.


              Another problem now presents itself: when the artwork is modified, nothing shows up for the Undo.  I am pushing the AppContext right before the artwork is modified (using the AppContext.hpp/cpp class).  I can't prove this yet, but I'm willing to bet that pushing the AppContext doesn't work as long as the extension window is still open.


              So, how to close the extension window before the plugin gets the event.  That's what I need to figure out.

              • 4. Re: Modal dialog extension
                Harbs. Level 6

                Why don't you use CSXSInterface to request the extension to close and then catch the event the same way you are with escape?

                • 5. Re: Modal dialog extension
                  T.Nelson Level 1

                  This still doesn't work.  The extension window is still open when the plugin gets the close notification, no matter how I approach it.  I think at this point I'm giving up and reworking the dialog to be modeless.  It shouldn't take two developers working on this for 4 days to try to figure out how to close a window.


                  Harbs, thanks for your suggestions.

                  • 6. Re: Modal dialog extension

                    At least on Mac, when a native dialog is shown on an modal extension window, both window's event handling get stuck.


                    The workaround I took was to use AITimerSuite.

                    When you receive an event, do nothing but store the event data and then activate a timer.

                    After the modal extension is closed, the timer fires and the plugin can do the queued job.

                    Hope this helps someone who cannot take modeless approach.

                    • 7. Re: Modal dialog extension

                      Hi ranvis, Nelson, Harbs

                      Are you get pressed ESC event before Modal dialog escape ?