ScripUI window updates only after callback function is executed
I built a ScriptUI palette, that calls a function, which takes some time to finnish.
While the function is running, I want to show, whats going on.
To archive this, I tried to change staticText in the palette, before running the function.
Unfortunately, the updated text only is shown after the function has finished. Here’s my code:
var dialog = new Window("palette");
var st_processing = dialog.add("statictext", undefined, undefined, {name: "st_processing", truncate: "end"});
st_processing.text = "";
st_processing.preferredSize.width = 240;
var ok = dialog.add("button", undefined, undefined, {name: "ok"});
ok.text = "OK";
ok.onClick = function(){
st_processing.text = "Doing something …";
function_one();
// st_processing.text = "";
// function_two();
// dialog.close();
};
dialog.show();
function function_one(){
// do sth.
}
If I un-comment the last three lines in the onClick function, I don’t see anything.
The way it is now, the function is run and the text is updated only after the function has finnished.
I tried changing the size of staticText (similar to what Peter Karel is describing in »Fixing display problems in listbox controls« on p 40 in his ScriptUI tutorial).
st_processing.text = "Doing something …";
var s = st_processing.size;
st_processing.size = [s[0] + 1, s[1] + 1];
st_processing.size = s;Unfortunately this doesn’t help.
I also tried this:
st_processing.text = "Doing something …";
st_processing.refresh();This does actually show the message immediately.
But this way the function is never run.
Is there a way, to show the updated text immediately?
Thanks for any suggestions,
Martin

