Page 1 of 1
Get a Number of line in Field
Posted: Thu Dec 03, 2009 9:57 am
by Vincent
Hi,
I would like to get the number of the cliked line in a field to change its backgroundcolor. So, I tried with the "mouseline" function and the "clickline", but it doesn't work...
Someone could help me, please ?
Thanks in advance,
Vincent.
Re: Get a Number of line in Field
Posted: Thu Dec 03, 2009 2:30 pm
by ale870
Hello,
I used a trick to make it.
I lock the screen, then select the char (chunk) where the caret (cursor) is located. Finally I use "selectedLine" to check line number!
Re: Get a Number of line in Field
Posted: Fri Dec 04, 2009 4:55 pm
by dunbarx
How do you intend to change the color? Just by clicking on a line? If so, and if the field is locked:
Code: Select all
on mouseup
put word 2 of the clickLine into tLine --you asked for the line number. not needed, though
set the foregroundColor of the clickline to any item of "red,green,blue,yellow"
end mouseup
If the field is not locked you need to decide how you want to handle the operation. You might use something like the trick suggested, to temporarily lock the field. Note also that holding the commandKey down while clicking will send a mouseUp message to the field, and you can use the handler above.
Re: Get a Number of line in Field
Posted: Fri Dec 04, 2009 5:07 pm
by ale870
In order to detect current line number, you can use this code:
Code: Select all
local myRnd
on arrowKey
put random(100000) into myRnd
send "aggiorna" && myRnd to me in 100 milliseconds
pass arrowKey
end arrowKey
on aggiorna arg1
if arg1 is myRnd then
put the selectedLine into field "fldLine"
end if
end aggiorna
Put it in the Field (your text editor). Time delay will prevent wrong line numbers, and will speed up cursor movements (update cursor position only if the user stop cursor movement).
Field "fldLine" is another field used to show current line number.