textEditor string compare confusion


#1

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.


#2

Well, I tried “compareNatural” and it works. But seems expensive, maybe. Shouldn’t matter for my app.

I’d still like to know what’s going on…

cheers,
-eric


#3

Well, in case this comes up for anyone else, there is a solution for the ‘dirty’ flag issue in the MDI panel of the Juce Demo. Not sure quite how it works, but I think I can use it regardless.

-e