Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Textfield Different color text within text - Gideros Forum

Textfield Different color text within text

talistalis Guru
edited November 2017 in General questions
Is there anyway to highlight some text with different color by using new textField.
I tried some weird methods like combining more than one textfiled together but can not be successfull so much. (Except some minor cases)
The problem with combining more than one textfield is i can not find the correct place (x,y) coordinate where the textField finished.
In addition when allignment takes part this logic totaly fails. Maybe some idea to point me out?

Previously with textwrap i coded something like this. But now we have builtin working like a charm Textfield with alignment i am trying to achieve some similar logic.
Quote starts from old textwrap class:
I had something in mind like this when i started:
@" in the beginning of the lines. And the code will recognize them and format my line according to correspending parameters.
Example inside txt file:
This is a test line.
@This is a test line.

@ line will be green color. But the first line will be black as default.

Quote Finished:

Fullcode with old textwrap:
http://giderosmobile.com/forum/discussion/1580/textwrap-addition/p1


My simple code just to demonstrate my idea with Textfield:
local textLines = {
  "this is a blue text",
  "here comes the green text",
  "This is a reddish one"
}
local textField = TextField.new(nil, "")
local textField2 = TextField.new(nil, "")
--1st textfield
textField:setPosition(100, 100)
textField:setTextColor(0x88bbdd)
stage:addChild(textField)
textField:setText(textLines[1])
 
a=textField:getWidth() 
b=textField:getWidth() 
 
--2nd textfield
textField2:setPosition(100+a, 100)
textField2:setTextColor(0x119900)
textField2:setText(textLines[2])	-- set new text
stage:addChild(textField2)
«1

Comments

Sign In or Register to comment.