[fxruby-users] Styled text on arrays

Lyle Johnson
Mon, 01 Dec 2008 16:16:04 -0000

On Dec 1, 2008, at 7:00 AM, Stuart Clarke wrote:

> I was wondering can I use styled text to assign one occurance of
> @evtrievefindings.push as being in the colour red, eg.
>
> if 100
> @evtrievefindings.push "info"
> end
> if 200
> @evtrievefindings.push.changestyle "different info"
> end
>
> Does this make sense? Basically I want my program to write the
> contents of the array to the text frame as normal but when data
> meets one criteria I want the data written to the array to be a
> colour.

If what you''re asking is whether you can embed some sort of markup in
the text itself to change the text style (e.g. as you do with HTML),
and the answer to that question is no.

What you might want to investigate is appending text to the FXText
window incrementally (instead of setting the content in one fell
swoop), e.g.

	@evtrievefindings.each do |finding|
		text_widget.appendText(finding + "\n")
	end

And then once you''ve got that working, switch over to using styled
text. You would still need to keep some sort of indicator in the
@etrievefindings array (or a parallel array), but you could at least
know which style to apply:

	@etrievefindings.each do |finding|
		if condition1
			text_widget.appendStyledText(finding + "\n", style1)
		else
			text_widget.appendStyledText(finding + "\n", style2)
		end
	end

Hope this helps,

Lyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/fxruby-users/attachments/20081201/c23f7465/attachment.html>