NSTextField not updating...

I have an NSTextField, a label, that I want to change a few times while my app is running. I made the following method:

on setProgressComment_(myString)
		set myString to myString as string
		log myString
		progressCommentTextField's setStringValue_(myString)
	end setProgressComment_

At several places in my code I inserted lines like:

setProgressComment_("Now doing A")
-- Code for doing A
setProgressComment_("Now doing B")
-- Code fror doing B

However, only the first invocation of my method changes the textField at runtime, after that, it remains stuck on “Now doing A”. Until the very end when the following line appears:

setProgressComment_("")

Which successfully clears the Text field

The debugger Console shows the method being called with the correct string, it’s just the text field that doesn’t update. Any idea what might be going on here?

It looks like it should work, from what you’ve posted. It would be helpful if you posted your whole code or a test program that recreates the problem.

Ric

Your problem is that screen updating normally takes place after each event is handled, and in this case probably means when your code has finished running.

You will need to insert:

theWindow's displayIfNeeded() 

wherever you want the window to update (theWindow being a property connected to your window in IB).

Thanks Shane, that’s the ticket. I made one modification to your solution, I targeted the textField directly rather than the entire window:

on setProgressComment_(myString)
     set myString to myString as string
     log myString
     progressCommentTextField's setStringValue_(myString)
     progressCommentTextField's displayIfNeeded() 
end setProgressComment_

Works a treat. Thanks