position of text-curson within field

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

position of text-curson within field

J. Landman Gay via use-livecode
I'm trying to script a special backspace script.

As is the usual backspace behavior, I still want the char to the left of
the flashing cursor to be deleted. Wherever that cursor happens to be.

But because the backscape key cannot get passed, it seemsI have to manually
delete that character to the left of the flashing cursor (wherever the
cursor happens to be).

So, how do I find out in terms of relative character position (eg. char 275
of field x) where within a text field is the flashing cursor?

Something like:

on backspaceKey
 put the <<position of the flashing cursor>> in field x into tPos
 -- e.g. tPos = char 275 of field x
 delete char tPos of field x
 put the number of lines in field x into field "Nr of lines"
end backspaceKey

As you can see, the reason I'm interrupting the backspace key is to find
out the number of lines in a field after a char is deleted.

--
Nicolas Cueto
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: position of text-curson within field

J. Landman Gay via use-livecode
On 02/19/2018 05:01 PM, Nicolas Cueto via use-livecode wrote:

> As you can see, the reason I'm interrupting the backspace key is to find
> out the number of lines in a field after a char is deleted.

I would do that differently:

local sHowManyLines

on backspaceKey
   send "howManyLinesNow" to me in 0 milliseconds
   pass backspaceKey
end backspaceKey

on howManyLinesNow
   put the number of lines of me into sHowManyLines
end howManyLinesNow

--
  Mark Wieder
  [hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: position of text-curson within field

J. Landman Gay via use-livecode
Thanks, Mark.

Strange, during devpt I couldn't press "apply" in the script editor when I
had the line "pass backspaceKey"... Maybe I misspelt...

--
Nicolas Cueto

On 20 February 2018 at 10:42, Mark Wieder via use-livecode <
[hidden email]> wrote:

> On 02/19/2018 05:01 PM, Nicolas Cueto via use-livecode wrote:
>
> As you can see, the reason I'm interrupting the backspace key is to find
>> out the number of lines in a field after a char is deleted.
>>
>
> I would do that differently:
>
> local sHowManyLines
>
> on backspaceKey
>   send "howManyLinesNow" to me in 0 milliseconds
>   pass backspaceKey
> end backspaceKey
>
> on howManyLinesNow
>   put the number of lines of me into sHowManyLines
> end howManyLinesNow
>
> --
>  Mark Wieder
>  [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode