Page 1 of 1

Higlighting text

Posted: Thu Sep 17, 2009 3:40 am
by mtecedor
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

Posted: Thu Sep 17, 2009 8:46 am
by Mark
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

Posted: Thu Sep 17, 2009 1:10 pm
by mtecedor
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

Posted: Thu Sep 17, 2009 1:21 pm
by Mark
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

Posted: Thu Sep 17, 2009 2:25 pm
by bn
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