6 Replies Latest reply on Feb 18, 2011 2:42 AM by meeky

    Open Modal Dialog in Photoshop (Mac)

    meeky Level 1

      I can't seem to open a modal dialog in Photoshop on the Mac with the CS SDK. The code works fine in InDesign. In Photoshop, the modality is there (the application responds to mouse clicks with a bell) but the window is not visible. Here is my mx:WindowedApplication:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
           <mx:Script>
                <![CDATA[
                     import com.adobe.csxs.types.CSXSWindowType;
                     import mx.core.Window;
                     
                     protected function onClick(event:MouseEvent):void
                     {
                          var w:Window = new TestDialog();
                          if (w) {
                               w.type = CSXSWindowType.MODAL_DIALOG;
                               w.resizable = false;
                               w.open();
                          }
                     }
      
                ]]>
           </mx:Script>
           <mx:Button x="10" y="10" label="Open Popup" click="onClick(event)"/>
      </mx:WindowedApplication>
      

       

      The Window itself is more or less copied from the "MakeSideHeads" sample project:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Window xmlns:mx="http://www.adobe.com/2006/mxml" 
                   title="Test" 
                   titleAlignment="center"
                   layout="absolute" 
                   width="300" 
                   height="100"
                   showStatusBar="false">
           <mx:Script>
                <![CDATA[
                     private function myCloseWindow():void{
                          this.close();
                     }
                ]]>
           </mx:Script>
           <mx:Canvas width="100%" height="100%" id="TestPanel" backgroundColor="#D2D2D2">
                <mx:VBox verticalAlign="middle" horizontalAlign="center" height="100%" width="100%">
                     <mx:HBox height ="90%" width="100%">
                          <mx:Text width="100%" height="100%" text="Some Text"/>
                     </mx:HBox>
                     <mx:HBox  height = "10%" horizontalAlign="center">
                          <mx:Button id="CloseButton" label="Close" click="myCloseWindow()" />
                     </mx:HBox>
                </mx:VBox>
           </mx:Canvas>
      </mx:Window>
      

       

      This seems like quite a significant bug. Or am I missing something?

        • 1. Re: Open Modal Dialog in Photoshop (Mac)
          meeky Level 1

          The modal opens in Photoshop on Windows.

          I guess the problem could be related to the issue dealt with by Bob Stucky in his Cookbook article

          But I can't see how the workaround would help here –  I can't see a System/Asynchronous event to use the

          PsEventScrubber with.

          • 2. Re: Open Modal Dialog in Photoshop (Mac)
            DBarranca Level 4

            Hi meeky,

             

            have you tried with a <mx:Application> instead of <mx:WindowedApplication>?

            Never had any problem with the former one, Photoshop + Mac.

            Let us know,

             

            Davide

            1 person found this helpful
            • 3. Re: Open Modal Dialog in Photoshop (Mac)
              meeky Level 1

              @DBarranca. Thanks for the response. I tried your suggestion with mx:Application but there is still no visible dialog.

               

              I'm actually using CSXSWindowedApplication in my real extension (as  opposed to this stripped-down test code) because I depend on AIR-only  functionality.

              I'm using Snow Leopard if that's relevant.

              Also If I try CSXSWindowType.MODELESS or CSXSWindowType.PANEL instead of CSXSWindowType.MODAL_DIALOG, I do see the new Window but it's inside of the existing extension panel, and clicking on the close button closes the whole thing.

              • 4. Re: Open Modal Dialog in Photoshop (Mac)
                DBarranca Level 4

                Hello,

                I've tested this one and it works.

                 

                main.mxml

                 

                <?xml version="1.0" encoding="utf-8"?>
                <csxs:CSXSWindowedApplication xmlns:csxs="com.adobe.csxs.core.*" 
                     xmlns:mx="http://www.adobe.com/2006/mxml" 
                     historyManagementEnabled="false">
                     <mx:Script>
                          <![CDATA[
                               import com.adobe.csxs.types.CSXSWindowType;
                               import mx.core.Window;
                               import ModalDialog;
                
                               public function showModal():void
                               {
                                    var window:Window = new ModalDialog;
                                    window.type = CSXSWindowType.MODAL_DIALOG;
                                    window.resizable = false;
                                    window.open();
                               }
                          ]]>
                     </mx:Script>     
                          <mx:Button label="Display Modal Dialog" click="showModal()"/>          
                </csxs:CSXSWindowedApplication>
                
                

                 

                The following is the ModalDialog.mxml

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Window 
                     xmlns:mx="http://www.adobe.com/2006/mxml" 
                     layout="absolute" 
                     width="300" 
                     height="200"
                     creationComplete="onCreationComplete()" 
                     title="Modal Dialog"
                     >
                     <mx:Script>
                          <![CDATA[
                               private function onCreationComplete():void
                               {
                                    //Center the window on the screen
                                    var screenBounds:Rectangle = Screen.mainScreen.bounds;
                                    nativeWindow.x = (screenBounds.width - nativeWindow.width) / 2;
                                    nativeWindow.y = (screenBounds.height - nativeWindow.height) / 2;
                               }
                          ]]>
                     </mx:Script>
                     <mx:VBox verticalAlign="middle" textAlign="center" horizontalAlign="center">
                          <mx:HBox horizontalAlign="center">
                               <mx:Label text = "This is an example of a modal dialog box."/>
                          </mx:HBox>
                          <mx:HBox horizontalAlign="center">
                               <mx:Button label = "Close" click="close()"/>
                          </mx:HBox>
                     </mx:VBox>
                </mx:Window>
                
                

                1 person found this helpful
                • 5. Re: Open Modal Dialog in Photoshop (Mac)
                  meeky Level 1

                  Thank you very much for so kindly taking the time to look at this.

                  Your code does indeed launch a modal dialog in Snow Leopard PS CS5. On my system, there are still a few significant issues however - the window appears as a sliver with zero width. If I set resizable to true before opening it, and then set the width of the nativeWindow in onCreationComplete then I do get a properly sized Dialog. The next problem is that it is blank - there is no content inside the dialog – just white space. Since the dialog is working fine for you, I'm guessing there must be something strange about my local setup/install. I will continue to investigate and will post if I find a solution.

                  • 6. Re: Open Modal Dialog in Photoshop (Mac)
                    meeky Level 1

                    Thanks in large part to DBarranca, this is working for me now. The problem was in my manifest.xml. I had defined a maximum and minimum size but not a plain old Size for my panel. It didn't seem to matter until now, but there you go.

                     

                    <UI>
                         <Type>Panel</Type>
                         <Menu>TestPlugin</Menu>
                         <Geometry>
                              <Size>
                                   <Height>200</Height>
                                   <Width>350</Width>
                              </Size>
                              <MaxSize> 
                                   <Height>492</Height>
                                   <Width>221</Width>
                              </MaxSize>
                              <MinSize>
                                   <Height>300</Height>
                                   <Width>221</Width>
                              </MinSize>
                         </Geometry>
                    </UI>