JUCE_LIVE_CONSTANT && newlines


#1

So I’m trying out the new JUCE_LIVE_CONSTANT stuff and it’s cool… but I decided to try a multiline string…

In my class constructor I’ve set the String variable:

m_szMyString = JUCE_LIVE_CONSTANT ("Some text starts here\r\nand the next line.");

in my paint() method I have:

    int x = JUCE_LIVE_CONSTANT(600);
    int y = JUCE_LIVE_CONSTANT(75);
    int w = JUCE_LIVE_CONSTANT(300);
    
    g.drawMultiLineText (m_szMyString, x, y, w);

if m_szMyString doesn’t use the JUCE_LIVE_CONSTANT the code works okay and I can adjust x, y and w… but if I use JUCE_LIVE_CONSTANT with the string containing \r\n I get an assert in TextEditor::setText() at line 1185

        // if you're adding text with line-feeds to a single-line text editor, it
        // ain't gonna look right!
        jassert (multiline || ! newText.containsAnyOf ("\r\n"));

The only other thing… I have to force a repaint to see the changes…

JUCE_ENABLE_LIVE_CONSTANT_EDITOR is defined.

Thanks,

Rail


#2

Ok, I guess I could add something to set the editor to multi-line mode if the original text contains a new-line.


#3

Yeah, I’d tried that… But it’s not that simple, 'cause the new lines are still interpreted as new lines… TextEditor would need to be modified to display the escape characters (\r and \n)

Cheers,

Rail


#4

Just tested the updates and they’re working well.

Cheers,

Rail