Hi,
in Photoshop ScriptUI 'dialog' Windows are supported (they're modal windows), while 'palette' Window's behavior is peculiar (they're non-modal, and as long as there's something going on in the script, they keep displaying - otherwise they automatically close). Apparently, this is different in InDesign (for instance), where palettes can stay idle - at least this is what I've been told.
I've found a couple of workarounds to work with palette Windows (my goal is to show them in order to let the user interact with either PS and the script's GUI - just like you'd do with regular panels and extensions - that is: to work with them as non-modal, idle palettes that mimic extension behavior), namely:
// usual Window stuff
win.show()while (isDone === false) {// isDone is set true in win.onClose() etc. app.refresh();}
or
var s2t = function(stringID) { return app.stringIDToTypeID(stringID);};
var waitForRedraw = function() { var d; d = new ActionDescriptor(); d.putEnumerated(s2t('state'), s2t('state'), s2t('redrawComplete')); return executeAction(s2t('wait'), d, DialogModes.NO);}; // Window stuffwhile (isDone === false) {// isDone is set true in win.onClose() etc. waitForRedraw()}
The problem is as follows:
1. They both work on Mac, either CS5 and CS6
2. app.refresh() seems to work on PC + CS5, but not PC + CS6
3. waitForRedraw() fails on both PC + CS5 and PC + CS6.
Mind you: When I wrote that the workarounds fails in CS5 and/or CS6 on PC, I mean that the 'palette', idle windows are modal and not non-modal as it is on Mac (which is my main coding platform).
[EDIT] Further testing has shown that PC palettes are... halfway between modal and non-modal. For instance, you can click on menus, but not select a Tool; you can collapse or drag a panel, but not access its content. You can't absolutely click on the image - for instance I'm desperately trying to enable panning on PC palettes: no way, you can't have the Hand tool to click&drag the image. For some reason, a "soft-scrolling" is enabled (on my MacBookPro, two fingers scrolling in all directions in the trackpad - but how to mimic this behavior in a desktop PC with no trackpad I don't know). Weirdly enough, the trackpad's "soft-scrolling" works in all directions on PC + CS5 64bits only, either CS5 @32bits, CS6 @32/64bits goes up and down only, no left/right allowed - frankly, to deal with platform-dependent issues is one thing, to take into account 32/64bits too is... ehm...
So, to sum up there are big differences in the ScriptUI behavior depending on how platform and PS version are combined:
PC, 'palette' Window:
CS5 + waitForRedraw() = modal
CS5 + app.refresh() = non-modal
CS6 + (app.refresh() OR waitForRedraw()) = modal
Mac, 'palette' Window:
(CS5 OR CS6) + (app.refresh() OR waitForRedraw()) = non-modal
Is there any... "working workaround" to make on PC CS6 a 'palette' ScriptUI Window to keep a non-modal, idling behavior? (the unasked question is: why is that palettes are behaving as non-modal in CS5 and not in CS6?! )
Thanks in advance!
Davide
Message was edited by: DBarranca - added blue text, further testing comparing 32/64bit versions