Piero, you’re right. My previous explanation incorrectly applied ordinary text-field behaviour to text areas. Sorry for the confusion.
My original Xojo test used two single-line text fields. On macOS, selecting text in one and tabbing to the other clears the first field’s selection. That observation was correct, but I drew too broad a conclusion from it.
After adding a textarea to the test, I confirmed that it retains its selection when focus moves elsewhere, with the highlight changing to grey. Your TextEdit example illustrates the distinction I missed. My statement that macOS permits only one selection per window was incorrect.
The important distinction is between keyboard focus, the selected range, and how that range is highlighted. Losing focus does not necessarily mean losing the selection, and a hidden highlight does not mean SelectionLength has become zero.
I’ve corrected Objo’s implementation. The behaviour in the next release will be:
| Platform | TextArea when focus moves to another control | TextField / SearchField when focus moves to another control |
| macOS | Selection retained; highlight becomes grey | Selection cleared |
| Windows | Selection retained; highlight hidden while unfocused | Selection retained; highlight hidden while unfocused |
| Linux | Selection retained; highlight remains visible | Selection retained; highlight remains visible |
Switching to another app or showing a dialog/message box preserves the selected range for all three controls on every platform. The macOS clearing rule for ordinary fields applies when focus moves to another control in the same window.
I also need to correct my earlier claim that every inactive selection is drawn dimmed. Its appearance depends on the platform and control, as described above.
For your TextArea preferences use case, SelectionStart, SelectionLength, and SelectedText will remain available after tabbing away, switching apps, or showing a message box. Returning focus preserves the selection; focus changes alone will no longer collapse it.
The fix is committed and marked fixed for the next release. I’ve updated the documentation and added regression coverage for selection retention, returning focus, inactive highlighting, and editing with undo/redo.
Cross-platform UI work is hard!