How to set cursor location

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
samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

How to set cursor location

Post by samjith » Mon Jun 22, 2015 12:42 pm

How to set the position of cursor in scrolling text field. I know the line number (say, line 15 of field 1), then how to set the position of cursor.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to set cursor location

Post by Klaus » Mon Jun 22, 2015 12:49 pm

Hi samjith,

check "select" in the dictionary, this will let you position the cursor in a field!

E.g. this will place the cursor at the beginning of line 15 of your field:
...
select before line 15 of fld "samjith's nice field"
...


Best

Klaus

samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

Re: How to set cursor location

Post by samjith » Mon Jun 22, 2015 1:13 pm

Hi Klaus,

Thanks for the quick reply. Code works fine.

I need certain replaces, if i select "replace_All" from my popup menu. The text in my screen moves automatically.

I want the changes, but i dont need to changes the text in the screen. :oops:

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to set cursor location

Post by Klaus » Mon Jun 22, 2015 1:49 pm

Hi samjith,
samjith wrote: I need certain replaces, if i select "replace_All" from my popup menu. The text in my screen moves automatically.
I want the changes, but i dont need to changes the text in the screen. :oops:
sorry, I'm afraid I don't understand what your problem is?


Best

Klaus

samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

Re: How to set cursor location

Post by samjith » Mon Jun 22, 2015 2:28 pm

Code: Select all

case Revert_Once
         put gmouse_line into RevertLine
         if backgroundColor of button "UK" is red then
            put the htmlText of  RevertLine into myR
            replace "<strike><font bgcolor=" & quote & "#FFFF00" & quote & ">" & gUS & "</font></strike><font bgcolor=" & quote & "#00FF00" & quote & ">" & gUK & "</font>" with "<font bgcolor=" & quote & "#00FF00" & quote & ">" & gUS & "</font>"  in myR 
            set the htmlText of  RevertLine to myR
            put myR into gmouse_line
         end if 
         if backgroundColor of button "US" is red then
            put the htmlText of  RevertLine into myR
            replace "<strike><font bgcolor=" & quote & "#FFFF00" & quote & ">" & gUK & "</font></strike><font bgcolor=" & quote & "#00FF00" & quote & ">" & gUS & "</font>" with "<font bgcolor=" & quote & "#00FF00" & quote & ">" & gUK & "</font>"  in myR 
            set the htmlText of  RevertLine to myR
            put myR into gmouse_line
         end if
         
         select before  LineFinder 
         --unlock screen
         --lock cursor
         break
This is one of the code in my popup menu.
I have a txt file of more than 1000 line in my scrolling field.
If i select the above mentioned code from my popup menu. then replacement works fine. But the problem is that the text in scrolling field scrolls automatically


It is very difficult for me, to find the current line i worked before selecting the popup menu.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to set cursor location

Post by Klaus » Mon Jun 22, 2015 2:38 pm

Hi samjith,

aha, now I get it (more or less) :D
I would try to store the current scroll of the field BEFORE replacing etc, and set it back again afterwards.
...
put the scroll of fld "your field here" into tOldScroll
case ...
## Do your replace etc. here...
...
set the scroll of fld "your field here..." to tOldScroll
break
...
At least worth a try!


Best

Klaus

samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

Re: How to set cursor location

Post by samjith » Tue Jun 23, 2015 5:44 am

Hi Klaus,

Code works fine. Thanks for giving that wonderfull idea. :D






Cheers

Samjith

Post Reply