Chat application: change color of word in global variable

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
starfirescully
Posts: 23
Joined: Wed Jul 09, 2014 2:35 pm

Chat application: change color of word in global variable

Post by starfirescully » Mon Jun 13, 2016 4:38 pm

Hello everyone,

I am creating a fake chat application for running an experiment.

I have the Subject ID which is different depending on each participant (Ex. AAAAAAA01; always seven letters and 2 numbers) so I have it in the global variable (as I call it on multiple cards) gSubjectID

An image of the window is attached

When the subject types something in and presses send, it displays the text after what is already there (so it is constantly updating)

Here is an example of the code in simplest form:

Code: Select all

on mouseUp
         
         put return after fld "chatfield"
         put gSubjectID & ":" & space & fld"textfield" after fld "chatfield"
         put empty into fld "textfield"
         wait 4 seconds
         put return & return  & Confederate & ":" & space & fld "OtherAnswer1" after fld "chatfield"
         add 1 to ChatCount
         
end 

An example of what it could display in the chat window:
Please wait connecting...
Connected
AAAAAAA01 has joined the room

AAAAAAA01: Hello this is my first chat message
This puts the Subject ID and : before whatever they type. I want the Subject ID to be a different color.

I have tried Htmltext but it only works for replacing everything in the new field not for updating the field with additional text.

Any thought? Is this even possible?
Last edited by starfirescully on Mon Jun 13, 2016 5:01 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Chat application: change color of word in global variabl

Post by dunbarx » Mon Jun 13, 2016 4:59 pm

Hi.

Make a field. Put several words of text into it. In the msg box;

Code: Select all

set the textColor of word 2 of fld "yourField" to "yellow"
Craig Newman

EDIT.

It occurs to me that learning how the htmlText property works might be really useful to you. It contains color information as well as styles.

Post Reply