Imagine you use a
TextEditor to display some text with formatting. You can do so using a couple of
insertTextAtCaret() calls. Usually this works fine.
However it doesn’t work if this happens while the text editor has focus. The change will often happen in response to some click which takes away that focus. What will happen is:
- A button click (or whatever) event arrives
- An asynchronous focus lost message is sent to the TextEditor
- You change the text in whatever callback you have
- The focus lost message arrives. This message will call
updateValueFromText()(see juce_TextEditor.cpp 1) and erase all the formatting.
So now what — of course I can send another asynchronous message to put in the formatted text, but how do I make sure it arrives after the focus lost message?
1: that’s a link. For some reason links don’t have styles at all over here. Web designers never cease to surprise me (in bad ways)