Use MouseLine() and still edit the same field?
Mark Mitchell
cowhead at mac.com
Sat Mar 5 08:17:49 EST 2016
Thanks to Devin, Terry and Matt
I tweaked Devin’s code a bit, and went with a global variable as otherwise it flashes and gives you an epileptic seizure!
But, this works great:
on mouseWithin — seems to work better than mousemove
global PastWhichLine
if pastWhichLine is empty then
put the mouseLine into pastwhichLine
end if
put the mouseline into tThisLine
if tThisLine <> PastWhichLine then
set the backgroundColor of pastwhichline to empty
set the backgroundColor of tThisLine to (220,220,250)
put tThisLine into PastWhichLine
end if
end mouseWithin
Thanks folks!
マーク.. (Apple mail has a bug that automatically changes my name to Japanese and there is no way to stop it… sigh…)
>
>> On Mar 4, 2016, at 1:08 PM, Mark Mitchell <cowhead at mac.com> wrote:
>>
>> (Sorry Heather! I?m sending this message again from the ?proper? account..)
>>
>> I?m not sure how long it has been around, but I have just discovered the ?mousewhithin? message combined with the mouseline() function? Awesome! So, for those of you who don?t know, the ?mousewithin? message is sent to a field periodically (5 times a second?) whenever the mouse is inside that field.
>>
>> Then, the mouseline function returns whatever line of that field the mouse is currently hovering over. I am currently using this to warn folks if they have too many characters per line. And that works fine.
>>
>> But to make it more intuitive, I want to somehow hilite or indicate the line that the mouse is over in the field, without disturbing the ability to edit that field (copy, paste, type stuff) with ease.
>>
>> I have tried a few different ways of hiliting the line of the field (selecting it, changing the color of the text of it, etc) but any sort of repeat or recursive structure does not work, as the ?mousewithin? message is simply sent far too often for any ?repeat? or recursion to work.
>>
>> Does anyone have any other ideas for highlighting a line in a field that might work under these conditions?
>
> Mark,
>
> Have you tried setting the backgroundColor of the line, something like this:
>
> local sCurrLine
>
> on mouseWithin
> put the mouseline into tThisLine
> if tThisLine <> sCurrLine then
> set the backgroundColor of line 1 to -1 of me to empty
> set the backgroundColor of tThisLine to (220,220,250)
> put tThisLine into sCurrLine
> end if
> end mouseWithin
>
> on mouseLeave
> set the backgroundColor of line 1 to -1 of me to empty
> end mouseLeave
>
> It seemed to work okay here on LC 7.1.2.
>
> Devin
>
> Devin Asay
> Office of Digital Humanities
> Brigham Young University
>
More information about the use-livecode
mailing list