Skip to main content
Known Participant
March 12, 2011
Answered

Modeless window using "palette" does not stay up in CS5

  • March 12, 2011
  • 3 replies
  • 6315 views

I am having trouble running a modeless dialog with CS5 (on Windows 64-bit).  My own script does not stay up and neither does the SnpCreateDialog.jsx snippet that  comes with the ESTK and is supposed to demonstrate modeless dialogs.  I have  tried:

  1. Running from the Scripts panel
  2. Add #target photoshop
  3. Being sure the drop-down menu says Photoshop, not CTSK

as suggested in an older discussion at http://forums.adobe.com/message/3008230#3008230.  (I decided to make a new discussion as that one was marked answered.)

It also does not stay up when moved into the Photoshop Scripts folder and run from the File menu in Photoshop.

The relevant code in SnpCreateDialog.jsx is:

function SnpCreateDialog() 
{
     this.windowRef = null;
}

/**
Functional part of this snippet.

Create a window of type "palette" (a modeless dialog) and display it.

@return True if the snippet ran as expected, false otherwise.
@type Boolean
*/
SnpCreateDialog.prototype.run = function()
{
     // Create a window of type palette.
     var win = new Window("palette", "SnpCreateDialog",[100,100,380,245]);  // bounds = [left, top, right, bottom]
     this.windowRef = win;
     // Add a frame for the contents.
     win.btnPanel = win.add("panel", [25,15,255,130], "SnpCreateDialog");
     // Add the components, two buttons
     win.btnPanel.okBtn = win.btnPanel.add("button", [15,65,105,85], "OK");
     win.btnPanel.cancelBtn = win.btnPanel.add("button", [120, 65, 210, 85], "Cancel");
     // Register event listeners that define the button behavior
     win.btnPanel.okBtn.onClick = function() {
          $.writeln("OK pressed");
          win.close();
     };
     win.btnPanel.cancelBtn.onClick = function() {
          $.writeln("Cancel pressed");
          win.close();
     };

     // Display the window
     win.show();
         
     return true;
         
}

/**
"main program": construct an anonymous instance and run it
  as long as we are not unit-testing this snippet.
*/
if(typeof(SnpCreateDialog_unitTest) == "undefined") {
    new SnpCreateDialog().run();
}


If  I put a breakpoint on the "return true;" line, then I can see that the dialog has, in fact, been created and is visible, but it has returned from win.show() and will go away as soon as the script continues.

Any help would be appreciated.

This topic has been closed for replies.
Correct answer Michael_L_Hale

Michael,

It was the CS Manual (the old one), not the CS5 manual that said it was not supported.  There is no indication it is not supported in CS5.  I don't have anything currently installed except CS5 to test if it works in intermediate versions.

I don't want it to stay up after the script exits, but I also don't want it to exit instantly after it is started.  Typically a dialog doesn't exit until show() completes, which happens when close() is called (by clicking Cancel, for example).  This one is exiting immeditely after show() is called.  It flashes by and does not stay open long enough to do anything with it.

If I change the simple ESTK example to a "dialog" rather than a "palette", then the script runs and stays up (as it should).  Apart from the fact that you should be able to do things in Photoshop while it is running, there should be no difference in its behavior.

A dialog is different from a panel.  I want a dialog.  A "modeless window that can display info to the user while the script is running", as you say, is exactly what I want.

The advantage of a modeless dialog is that you can continue to do things in Photoshop while the dialog is up.  At least I presume so, since I haven't got one to work, including the ESTK example.


Kenneth Evans wrote:

The advantage of a modeless dialog is that you can continue to do things in Photoshop while the dialog is up.  At least I presume so, since I haven't got one to work, including the ESTK example.

Sorry but no, most of the Photoshop UI is disabled while a script is running even if the script displays a palette window.

A dialog window does wait for show() to complete. That is what makes dialogs modal. A palette window does not wait for show() to complete. It runs the rest of the script.

In the example you posted all the script does after showing the window is return true then ends. Which is why all it does is flash the window. If you put a $.sleep(1000) line before the return true line the windows will display until sleep timeouts then the script will end and the window will close. That is why with Photoshop palette windows are really only useful for progress bars or other script status type windows.

Although palette windows may allow the user to intreact with the app UI while the window is displayed that doesn't work with Photoshop. The window only displays while the script is running and a running script limits Photoshop UI interaction.

I have tested palette windows in CS2, CS3, CS4, and CS5 with the same results. The window only shows while the script is running.

With Photoshop if you want the user to interact with the UI you have to create a panel.

3 replies

Inspiring
February 17, 2017

A good technique for keeping a palette window open to allow interacting with both the window and the document is discussed here, and works good: https://www.davidebarranca.com/2012/10/scriptui-window-in-photoshop-palette-vs-dialog/

Muppet_Mark-QAl63s
Inspiring
March 12, 2011

Funny… I posted almost the same question only today in another forum… because I couldn't work out what I was doing wrong either… They just don't stick around in Photoshop. As for the engine thing PS only has the one 'main' so 'session' won't cut it… Bridge and Illustrator don't have 'session' either but palettes persist until dismissed in those…

Paul Riggott
Inspiring
March 12, 2011

I don't think you can get it to stay open, what I would do is use an Inspector panel, one example ;-

http://www.ps-scripts.com/bb/viewtopic.php?f=19&t=3433&sid=f9c2477ee2f9e8d3afc1f1fe7ab642e6

Known Participant
March 13, 2011

I don't think you can get it to stay open, what I would do is use an Inspector panel, one example ;-

http://www.ps-scripts.com/bb/viewtopic.php?f=19&t=3433&sid=f9c2477ee2f 9e8d3afc1f1fe7ab642e6

Paul,

That example uses a TabbedPalette and is targeted for Bridge, which appears to have such an Object.  It doesn't work for me in Photoshop, and I don't see an equivalent.

Paul Riggott
Inspiring
March 13, 2011

Sorry yes its for Bridge, maybe you could use a Configurator panel or use Creative Suite SDK