Hello,
I'm having troubles finding my way through BridgeTalk, ScriptUI and History states.
My script creates some layers then pops up a ScriptUI 'dialog' Window, which controls (sliders, etc.) modify those newly created layers.
You can simplify the flux writing:
Code: Select allvar SetLayers = function() {
// do layer things
}
var PopWindow = function() {
// do Window things
}
app.suspendHistory('Single Step', 'SetLayers(); PopWindow()');
Actually, everything is written so that the whole script can be action-recordable. It works, I'm a happy dude, the window pops, the user sets the sliders as long as he likes, clicks OK and everything is recorded as a "Single Step" History status (i.e: SetLayers(), PopWindow() and subsequent user interaction).
Unluckily, I need the Window to be non-modal ('palette', and not 'dialog'), so I've used the BridgeTalk message workaround (as outlined here).
Compared to the previous scenario (the 'dialog' window), using 'palette' and BridgeTalk due to the asynchronous nature of the latter and/or the non-modal nature of the 'palette', every interaction that the user performs with the window after its creation escapes the "Single Step" History status.
That is, "Single Step" contains SetLayers(), PopWindow() but not subsequent user interaction. Bad times.
Any suggestion to make the BridgeTalk + 'palette' work like the 'dialog'? (single history status, so that I won't have troubles squeezing everything into a recordable step).
If you want to look at an actual example, I've posted some simplified demo code here.
Thanks in advance!
Davide
BridgeTalk, ScriptUI and History state problem
-
Mike Hale
BridgeTalk, ScriptUI and History state problem
Seems you are fighting a losing battle. You have found a way to have a non-modal ScriptUI window, which I think is very useful. But I also think that you are now facing the same problem that just running the script without BridgeTalk faces. That is still not really non-modal. The window still may be showing and allowing the user to interact with Photoshop but I think that when one of the scripts ends( and I think that maybe the BTCaller ) suspendHistory ends as well. So the remaining actions are recorded.
I think the best you can do is create a snapshot to save the current state of the document at the start of the script. Either way the user will lose the history but at least they can undo.
But I didn't think having a working non-modal window in Photoshop was possible without creating a custom panel. You are on the bleeding edge here. I tried:
1 moving where the suspendHistory line is placed.
2 having a suspendHistory in both caller and callee.
3 moving suspendHistory to the run callback.
And variations of those three and nothing worked. In fact most of the things I tried killed the window.
I think the best you can do is create a snapshot to save the current state of the document at the start of the script. Either way the user will lose the history but at least they can undo.
But I didn't think having a working non-modal window in Photoshop was possible without creating a custom panel. You are on the bleeding edge here. I tried:
1 moving where the suspendHistory line is placed.
2 having a suspendHistory in both caller and callee.
3 moving suspendHistory to the run callback.
And variations of those three and nothing worked. In fact most of the things I tried killed the window.