Higlighting text

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
mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Higlighting text

Post by mtecedor » Thu Sep 17, 2009 3:40 am

Hi again,

I want users to be able to highlight some words in a text field, but I have no idea how to do it. I have been reading the User guide and some of the entries in this forum but nothing is working. I tried with some like this:

on mouseEnter
set the backgroundcolor of selectedChunk to red
end mouseEnter

I also tried

on mouseEnter
set the linkHiliteColor to red
end mouseEnter

The dictionary says:
Use the linkHiliteColor property to make grouped text look and behave like links in a web browser.

Probably I am oversimplifying, I dont even know if my text is already groped. I would like users to have the option o highliting single words and chunks of text.

Marta

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Sep 17, 2009 8:46 am

Hi Marta,

Any editable text in any application, including Revolution, can be hilited, simply by clicking in the field and dragging he mouse while keeping the mouse button pressed.

What exactly is your problem and why do you want this?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Post by mtecedor » Thu Sep 17, 2009 1:10 pm

Hi Mark,

It seems that I didn't explain what I want correctly. I want the user, not me, to be able to highlight the text. So I write write the text in a label field, and I want to program the possibility of my user to highlight certain words when (s)he puts the mouse over the words. I am in the field of foreign language education, so, in some situations I just want to use a highlighting tool as a study technique, in others, I want to provide the user with interactive glosses.

Marta

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Sep 17, 2009 1:21 pm

Dear Marta,

Do you want to hilite text when the mouse hovers over/clicks on/moves away from/<fill in here> the text? Why do you use a label field and why can't you use a normal editable field?

You might want to check out the backColor property. You can set this property for idividual characters and word (actually in combinationw ith all chunk expressions). Read more bout the backColor property in the documentation.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4036
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Thu Sep 17, 2009 2:25 pm

Marta,
put this code into a text field

Code: Select all

local myOldWord
on mouseWithin
   put the mouseCharChunk into aChar
   put the number of words of char 1 to  (word 4 of aChar) of me into myWord
   if myOldWord is not "" then set the textColor of word myOldWord of me to ""
   set the textColor of word myWord of me to red
   put myWord into myOldWord
end mouseWithin

on mouseLeave
   if myOldWord is not "" then set the textColor of word myOldWord of me to ""
end mouseLeave
and see what it does. It works on locked an unlocked text fields.
regards
Bernd

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”