5 Replies Latest reply on Jul 1, 2015 9:19 AM by Peter Kahrel

    Bug? InDesign CC/CC2014 loses focus when closing ScriptUI dialog window

    DirkEBM

      When closing a "dialog" type window, created using ScriptUI from Extendscript, InDesign will lose focus as "active application" in Windows (7/8) and instead switch to another application in Windows altogether. This behavior does not occur on previous versions of InDesign (CS6 and earlier). I can easily reproduce the problem at my company on various machines (both on Windows 7 and Windows 8). The Mac OS version of InDesign does not seem to have this problem. Also, the problem does not seem to occur when using "palette" or "window" type ScriptUI windows.

        • 1. Re: Bug? InDesign CC/CC2014 loses focus when closing ScriptUI dialog window
          Peter Kahrel Adobe Community Professional & MVP

          Yes, this is an InDesign bug, which has been with us since at least CS6. It's very annoying. Please add your voice to the chorus of ScriptUI wails and log a bug here: Adobe - Feature Request/Bug Report Form

           

          Peter

          • 2. Re: Bug? InDesign CC/CC2014 loses focus when closing ScriptUI dialog window
            DirkEBM Level 1

            Hmm, I found that this problem only seems to occur when I make a control "active" before showing the dialog. If I make a control active in the onActivate event of the window, the problem disappears.

            • 3. Re: Bug? InDesign CC/CC2014 loses focus when closing ScriptUI dialog window
              Peter Kahrel Adobe Community Professional & MVP

              That's in itself an interesting observation, but I have the focus problem 

              also with scripts that don't use ScriptUI at all.

               

              Peter

               

              On Mon, 13 Oct 2014 08:38:27 +0100, DirkEBM <forums_noreply@adobe.com>

              • 4. Re: Bug? InDesign CC/CC2014 loses focus when closing ScriptUI dialog window
                o-marat Level 3

                In this example, InDesign does not lose focus.

                To activate the text field in the dialog box I used the event handler "onActivate".

                //@target indesign
                
                var dial = new Window ( 'dialog', 'Print', undefined );
                
                dial.eText2 = dial.add ( 'edittext' );
                dial.eText2.size = [ 207, 21 ];
                //dial.eText2.active = true; // If you use this line, InDesign loses focus
                
                var gr10 = dial.add ( 'group' )
                gr10.size = [ 400, 29 ];
                
                dial.btButton1 = gr10.add ( 'button', undefined, 'Standart Print &Window', { alignment: [ 'left', 'center' ] } );
                dial.btButton1.onClick = function () {dial.close ( 0 )};
                
                dial.btButton2 = gr10.add ( 'button', undefined, 'Print', { name: "ok" } );
                dial.btButton2.alignment = [ 'right', 'center' ];
                
                dial.btButton3 = gr10.add ( 'button', undefined, 'Cancel', { name: "cancel" } );
                
                dial.onActivate = function () { // If you use this handler, InDesign does not lose focus
                  dial.eText2.active = true;
                }
                
                dial.show ();
                
                • 5. Re: Bug? InDesign CC/CC2014 loses focus when closing ScriptUI dialog window
                  Peter Kahrel Adobe Community Professional & MVP

                  'Losing focus' can mean two things: (a) another application comes to the front or (b) InDesign stays in front but e.g. an insertion point it loses focus. Take these two functions, getInPutA() and getInputB(). They do the same thing, namely, return some string which is then inserted at the current insertion point. They activate the edittext control in different way and when I tried in 2014.2, InDesign stays the frontmost app and both lose focus in the same way. And not activating the control loses focus too.

                   

                  function getInputA(){
                    var w = new Window ('dialog');
                      w.input = w.add ('edittext {characters: 10, active: true}');
                      w.add ('button {text: "OK"}');
                    w.show();
                    return w.input.text;
                  }
                  
                  function getInputB(){
                    var w = new Window ('dialog');
                      w.input = w.add ('edittext {characters: 10}');
                      w.add ('button {text: "OK"}');
                        
                      w.onActivate = function () {
                        w.input.active = true;  
                      }
                  
                    w.show();
                    return w.input.text;
                  }
                  
                  app.selection[0].contents = getInputB();