Getting last Cursor position in Field when focus moves

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 365
Joined: Mon Jun 10, 2013 1:32 pm

Getting last Cursor position in Field when focus moves

Post by Lagi Pittas » Tue May 30, 2017 10:14 am

Hi

I am rolling my own keyboard and have the keys when pressed by finger/mouse going to a specified field.
Everythingh works nicely but the backspace key try as I might deletes from the last character.

Using this in the mouseup of the field

Code: Select all

on MouseUp
    local lnPos
    put word 2 of the selectedchunk into lnPos
    set the the uChunk of me to lnPos
end Mouseup
And deleteng from that character.

The problerm is to get the Mousup to work I have to lock the field.

I can get it to sort of work by unlocking the field but i really want it locked to make it foolproof - "just in case".
Nothing is foolproof - fools are so ingenious
This will be used on a tablet so I want control of what and when they can enter.

Is there an easy way of the user touching say the letter "C" in the string/line ABCDE in the field and show the/a cursor between B and C where any new inserts or deletions happen or shall I take the easy route and create a text field that they can edit and then append that to the "real field"

I hope I'm making sense here

Regards Lagi

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Getting last Cursor position in Field when focus moves

Post by dunbarx » Tue May 30, 2017 3:20 pm

Hi.

Off the top of my head, in a locked field with traversalOn set:

Code: Select all

on mouseUp
   if the target contains "field" then
   select before char (word 2 of the selectedChunk) of target
   end if
end mouseUp
Does this get you going?

Craig

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 365
Joined: Mon Jun 10, 2013 1:32 pm

Re: Getting last Cursor position in Field when focus moves

Post by Lagi Pittas » Tue May 30, 2017 4:23 pm

HI Craig

Thanks for that. In the end I decided to leave the field unlocked and used the mousemove to do what I wanted.

Code: Select all

on MouseMove
   local lnPos
   put word 2 of the selectedchunk into lnPos
   set the uPos of me to lnPos
   put lnPos
end MouseMove

on KeyDown
   local lnPos
   put word 2 of the selectedchunk into lnPos
   set the uPos of me to lnPos
   put lnPos
   pass KeyDown
end KeyDown
Seems to work although it is out by one which I have to allow for. The keydown routine isn't really needed but is useful when working on the PC.

Thanks again


Lagi

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”