I’m trying to get a reliable dirty flag for a textEditor component.
It’s not working to just put the flag in textChanged() because I’m getting calls to it that are not originating in my code.
So I’m trying to compare a stored value for the text in the editor. But I’m not getting the compare value I expect.
Basically I’m doing this:
String str(“my text”);
editor.setText(str);
and then elsewhere:
setDirty (editor.getText().compare(str) != 0);
compare returns -1. And If I printout substring(0,50) for both str and editor.getText(), the editor text shows one more character.
Is there a hidden character I need to strip to get the intended effect? I’ve tried trimming both strings to no avail.