Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: TextPanel and highlighting  (Read 1635 times)

Alzrius

  • Ensign
  • *
  • Posts: 5
    • View Profile
TextPanel and highlighting
« on: May 09, 2014, 10:00:49 PM »

Been playing for ~6 months, now trying to make a mod...

What's the correct way to highlight various elements within a programmatically constructed paragraph?  I'm calling highlightFirstInLastPara immediately after adding the text which contains the element to be highlighted, but in most cases nothing appears highlighted, and at most only one element is (it seems to be always the last one, and only if no more text is added to the paragraph afterwards.)

Instead of making multiple calls to appendToLastParagraph and highlightFirstInLastPara, should I construct the paragraph text and highlighting separately myself, and then pass this information in one call to each?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: TextPanel and highlighting
« Reply #1 on: May 10, 2014, 10:28:28 AM »

highlightFirstInLastPara() is a way to highlight the first occurrence of a string in the last paragraph. If you need multiple highlights, you want to use these two methods:

void highlightInLastPara(String ...strings);
void setHighlightColorsInLastPara(Color ...colors);

It doesn't matter whether you construct the paragraph text in one go or use appendToLastParagraph.

Other than that, it's hard to say what's going wrong without seeing your code (and knowing what you're expecting it to do).
Logged

Alzrius

  • Ensign
  • *
  • Posts: 5
    • View Profile
Re: TextPanel and highlighting
« Reply #2 on: May 10, 2014, 03:37:57 PM »

Ok, thanks; that makes sense.
Logged