Re: Cursor Placement in MobileControl

2024-03-06 Thread Mike Kerner via use-livecode
we don't have a universal field widget, and, the existing controls don't
make it easy to do things like this.
there are often ways to overcome, just like there are in c, but that
doesn't mean i prefer c
or swift
or java
or xojo
sometimes workarounds are a means to identify opportunities to improve the
product.

On Wed, Mar 6, 2024 at 5:04 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Also, and without trying to put too fine a point on it, I’d like to
> reiterate that Livecode is much less like a furniture store, and more like
> an Ikea furniture factory, where there are lots of different parts, and
> bits to hold the furniture together, but theoretically you could make any
> kind of furniture you like. I think what you are asking for is a piece of
> furniture, when you already have everything necessary to make your own
> coffee table. :-)
>
> Bob S
>
>
> > On Mar 6, 2024, at 11:11 AM, Mike Kerner via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > it would be nice to have a universal field widget, and be able to have
> this
> > sort of behavior be part of it...
> >
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Cursor Placement in MobileControl

2024-03-06 Thread Bob Sneidar via use-livecode
Also, and without trying to put too fine a point on it, I’d like to reiterate 
that Livecode is much less like a furniture store, and more like an Ikea 
furniture factory, where there are lots of different parts, and bits to hold 
the furniture together, but theoretically you could make any kind of furniture 
you like. I think what you are asking for is a piece of furniture, when you 
already have everything necessary to make your own coffee table. :-)

Bob S


> On Mar 6, 2024, at 11:11 AM, Mike Kerner via use-livecode 
>  wrote:
> 
> it would be nice to have a universal field widget, and be able to have this
> sort of behavior be part of it...
> 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Cursor Placement in MobileControl

2024-03-06 Thread Bob Sneidar via use-livecode
It’s too specific. For instance I always format phone numbers nnn-nnn- xnnn 
(the x is for extension). Some people bracket the area code with paras, some 
need the country code, some want to prepend 1+ etc. 

I was planning to have a format string of some sort, then follow that pattern 
as the user types. For instance: -- x the brackets 
indicating text to be replaced. I could exclude the brackets but I might want 
to have a format string that uses a literal n in the future, so I have to 
figure out how to do all that. 

Bob S


> On Mar 6, 2024, at 11:11 AM, Mike Kerner via use-livecode 
>  wrote:
> 
> it would be nice to have a universal field widget, and be able to have this
> sort of behavior be part of it...
> 
> On Wed, Mar 6, 2024 at 2:07 PM Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> 
>> That is damn handy. That could be massaged to work with a Livecode field
>> too. I’m going to work on that.
>> 
>> Bob S
>> 
>> 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Cursor Placement in MobileControl

2024-03-06 Thread Mark Smith via use-livecode
Very useful to know. Thanks Dan

Mark

Sent from my iPhone

> On Mar 6, 2024, at 7:13 PM, Mike Kerner via use-livecode 
>  wrote:
> 
> it would be nice to have a universal field widget, and be able to have this
> sort of behavior be part of it...
> 
>> On Wed, Mar 6, 2024 at 2:07 PM Bob Sneidar via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>> 
>> That is damn handy. That could be massaged to work with a Livecode field
>> too. I’m going to work on that.
>> 
>> Bob S
>> 
>> 
>>> On Mar 6, 2024, at 10:13 AM, Ralph DiMola via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>>> 
>>> Dan,
>>> 
>>> Nice... thanks!
>>> 
>>> Ralph DiMola
>>> IT Director
>>> Evergreen Information Services
>>> rdim...@evergreeninfo.net
>>> 
>>> -Original Message-
>>> From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On
>> Behalf
>>> Of Dan Friedman via use-livecode
>>> Sent: Wednesday, March 06, 2024 11:15 AM
>>> To: How to use LiveCode
>>> Cc: Dan Friedman
>>> Subject: Re: Cursor Placement in MobileControl
>>> 
>>> Panos,
>>> 
>>> Thank you for the suggestion!   That worked out well!   For anyone
>>> interested, here's the snippet for formatting a phone number as you type
>> in
>>> a mobile native field control:
>>> 
>>> //this assumes that the mobileControl type for Android is "multiline" and
>>> the mobileSetKeyboardType has been set to "email"
>>> 
>>> on inputTextChanged
>>> put mobileControlTarget() into pField
>>> put mobileControlGet(pField,"text") into pText
>>> 
>>> if pField = "phoneNumber" then
>>>   put "" into fText
>>>   put numbersOnly(pText) into pText
>>> 
>>>   if char 1 of pText = "1" then
>>> put "" into fText
>>> mobileControlSet "phoneNumber","text",fText
>>> androidGoLastChar "phoneNumber",fText
>>> put fText into dataEntered["phone"]
>>> exit inputTextChanged
>>>   end if
>>> 
>>>   if the number of chars in pText < 4 then
>>> put pText into fText
>>> mobileControlSet "phoneNumber","text",fText
>>> androidGoLastChar "phoneNumber",fText
>>>   else
>>> if (the number of chars in pText > 3) then
>>>   put "(" & char 1 to 3 of pText & ")" into char 1 to 3 of fText
>>>   put " " & char 4 to 6 of pText after fText
>>> end if
>>> if the number of chars in pText > 6 then
>>>   put "-" & char 7 to 10 of pText after fText
>>> end if
>>> 
>>> mobileControlSet "phoneNumber","text",fText
>>> androidGoLastChar "phoneNumber",fText
>>>   end if
>>> end if
>>> end inputTextChanged
>>> 
>>> function numbersOnly pNum
>>> //returns only the numbers in pNum
>>> put "" into fNum
>>> repeat for each char c in pNum
>>>   if isNumber(c) then
>>> put c after fNum
>>>   end if
>>> end repeat
>>> 
>>> return fNum
>>> end numbersOnly
>>> 
>>> on androidGoLastChar mControl,xText
>>> if ("Android" is in the platform) then
>>>   mobileControlSet mControl,"selectedRange",(the number of chars in
>>> xText+1,0)
>>> end if
>>> end androidGoLastChar
>>> 
>>> 
>>> Thank you!
>>> 
>>> Dan Friedman
>>> CEO, ClearVision Technologies, LLC
>>> Voice: 909/484-2052
>>> http://www.clearvisiontech.com
>>> 
>>> 
>>> From: use-livecode  on behalf of
>>> panagiotis merakos via use-livecode 
>>> Date: Tuesday, March 5, 2024 at 9:45 AM
>>> To: How to use LiveCode 
>>> Cc: panagiotis merakos 
>>> Subject: Re: Cursor Placement in MobileControl Hello Dan,
>>> 
>>> I take it you are formatting the text in inputTextChanged?
>>> 
>>> Unfortunately yes, on Android calling
>>> 
>>> mobileControlSet "phoneNumber","text", pText
>>> 
>>> puts the cursor in the beginning of the text:
>>> 
>>> https://quality.livecode.com/show_bug.cgi?id=24055
>>> 
>>> RE using the selectedRange with mobile native controls, I think this
>>> property is supported only on multiline input fields. So I suppose you
>> could
>>> make the fields to be multiline and give it a try.
>>> 
>>> Kind regards,
>>> Panos
>>> --
>>> 
>>> On Tue, 5 Mar 2024 at 18:53, Dan Friedman via use-livecode <
>>> use-livecode@lists.runrev.com> wrote:
>>> 
 I am trying to create a field on mobile (iOS and Android) that will
 format a phone number as your type (client request).  I am able to do
 this on iOS as the command: mobileControlSet
 "phoneNumber","text",pText puts the cursor AFTER the text so the user
 can simply continue typing.  But, on Android, the cursor is placed at
>> the
>>> beginning of the text after the
 mobileControlSet command is called.   Is there a way to set the position
>>> of
 the cursor on a native mobile text field?
 
 I did notice that the Android Native Field widget has a selectedRange
 property.  Can I use this property on a native Android control?  And,
 can I set the selectedRange to "16,15" to set the cursor location, not
 select text?
 
 Why not just use the Android Native Field widget, you ask?   I will if I
 have to. but I prefer to use the native control as it is
 cross-platform and I don't need to case 

Re: Cursor Placement in MobileControl

2024-03-06 Thread Mike Kerner via use-livecode
it would be nice to have a universal field widget, and be able to have this
sort of behavior be part of it...

On Wed, Mar 6, 2024 at 2:07 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> That is damn handy. That could be massaged to work with a Livecode field
> too. I’m going to work on that.
>
> Bob S
>
>
> > On Mar 6, 2024, at 10:13 AM, Ralph DiMola via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Dan,
> >
> > Nice... thanks!
> >
> > Ralph DiMola
> > IT Director
> > Evergreen Information Services
> > rdim...@evergreeninfo.net
> >
> > -Original Message-
> > From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On
> Behalf
> > Of Dan Friedman via use-livecode
> > Sent: Wednesday, March 06, 2024 11:15 AM
> > To: How to use LiveCode
> > Cc: Dan Friedman
> > Subject: Re: Cursor Placement in MobileControl
> >
> > Panos,
> >
> > Thank you for the suggestion!   That worked out well!   For anyone
> > interested, here's the snippet for formatting a phone number as you type
> in
> > a mobile native field control:
> >
> > //this assumes that the mobileControl type for Android is "multiline" and
> > the mobileSetKeyboardType has been set to "email"
> >
> > on inputTextChanged
> >  put mobileControlTarget() into pField
> >  put mobileControlGet(pField,"text") into pText
> >
> >  if pField = "phoneNumber" then
> >put "" into fText
> >put numbersOnly(pText) into pText
> >
> >if char 1 of pText = "1" then
> >  put "" into fText
> >  mobileControlSet "phoneNumber","text",fText
> >  androidGoLastChar "phoneNumber",fText
> >  put fText into dataEntered["phone"]
> >  exit inputTextChanged
> >end if
> >
> >if the number of chars in pText < 4 then
> >  put pText into fText
> >  mobileControlSet "phoneNumber","text",fText
> >  androidGoLastChar "phoneNumber",fText
> >else
> >  if (the number of chars in pText > 3) then
> >put "(" & char 1 to 3 of pText & ")" into char 1 to 3 of fText
> >put " " & char 4 to 6 of pText after fText
> >  end if
> >  if the number of chars in pText > 6 then
> >put "-" & char 7 to 10 of pText after fText
> >  end if
> >
> >  mobileControlSet "phoneNumber","text",fText
> >  androidGoLastChar "phoneNumber",fText
> >end if
> >  end if
> > end inputTextChanged
> >
> > function numbersOnly pNum
> >  //returns only the numbers in pNum
> >  put "" into fNum
> >  repeat for each char c in pNum
> >if isNumber(c) then
> >  put c after fNum
> >end if
> >  end repeat
> >
> >  return fNum
> > end numbersOnly
> >
> > on androidGoLastChar mControl,xText
> >  if ("Android" is in the platform) then
> >mobileControlSet mControl,"selectedRange",(the number of chars in
> > xText+1,0)
> >  end if
> > end androidGoLastChar
> >
> >
> > Thank you!
> >
> > Dan Friedman
> > CEO, ClearVision Technologies, LLC
> > Voice: 909/484-2052
> > http://www.clearvisiontech.com
> >
> >
> > From: use-livecode  on behalf of
> > panagiotis merakos via use-livecode 
> > Date: Tuesday, March 5, 2024 at 9:45 AM
> > To: How to use LiveCode 
> > Cc: panagiotis merakos 
> > Subject: Re: Cursor Placement in MobileControl Hello Dan,
> >
> > I take it you are formatting the text in inputTextChanged?
> >
> > Unfortunately yes, on Android calling
> >
> > mobileControlSet "phoneNumber","text", pText
> >
> > puts the cursor in the beginning of the text:
> >
> > https://quality.livecode.com/show_bug.cgi?id=24055
> >
> > RE using the selectedRange with mobile native controls, I think this
> > property is supported only on multiline input fields. So I suppose you
> could
> > make the fields to be multiline and give it a try.
> >
> > Kind regards,
> > Panos
> > --
> >
> > On Tue, 5 Mar 2024 at 18:53, Dan Friedman via use-livecode <
> > use-livecode@lists.runrev.com> wrote:
> >
> >> I am trying to create a field on mobile (iOS and Android) that will
> >> format a phone number as your type (client request).  I am able to do
> >> this on iOS as the command: mobileControlSet
> >> "phoneNumber","text",pText puts the cursor AFTER the text so the user
> >> can simply continue typing.  But, on Android, the cursor is placed at
> the
> > beginning of the text after the
> >> mobileControlSet command is called.   Is there a way to set the position
> > of
> >> the cursor on a native mobile text field?
> >>
> >> I did notice that the Android Native Field widget has a selectedRange
> >> property.  Can I use this property on a native Android control?  And,
> >> can I set the selectedRange to "16,15" to set the cursor location, not
> >> select text?
> >>
> >> Why not just use the Android Native Field widget, you ask?   I will if I
> >> have to. but I prefer to use the native control as it is
> >> cross-platform and I don't need to case out for which platform we're
> >> on.  You would need to create the control and hide the widget for iOS
> >> and show the widget for Android.  I'll also 

Re: Cursor Placement in MobileControl

2024-03-06 Thread Bob Sneidar via use-livecode
That is damn handy. That could be massaged to work with a Livecode field too. 
I’m going to work on that. 

Bob S


> On Mar 6, 2024, at 10:13 AM, Ralph DiMola via use-livecode 
>  wrote:
> 
> Dan,
> 
> Nice... thanks!
> 
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdim...@evergreeninfo.net
> 
> -Original Message-
> From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
> Of Dan Friedman via use-livecode
> Sent: Wednesday, March 06, 2024 11:15 AM
> To: How to use LiveCode
> Cc: Dan Friedman
> Subject: Re: Cursor Placement in MobileControl
> 
> Panos,
> 
> Thank you for the suggestion!   That worked out well!   For anyone
> interested, here's the snippet for formatting a phone number as you type in
> a mobile native field control:
> 
> //this assumes that the mobileControl type for Android is "multiline" and
> the mobileSetKeyboardType has been set to "email"
> 
> on inputTextChanged
>  put mobileControlTarget() into pField
>  put mobileControlGet(pField,"text") into pText
> 
>  if pField = "phoneNumber" then
>put "" into fText
>put numbersOnly(pText) into pText
> 
>if char 1 of pText = "1" then
>  put "" into fText
>  mobileControlSet "phoneNumber","text",fText
>  androidGoLastChar "phoneNumber",fText
>  put fText into dataEntered["phone"]
>  exit inputTextChanged
>end if
> 
>if the number of chars in pText < 4 then
>  put pText into fText
>  mobileControlSet "phoneNumber","text",fText
>  androidGoLastChar "phoneNumber",fText
>else
>  if (the number of chars in pText > 3) then
>put "(" & char 1 to 3 of pText & ")" into char 1 to 3 of fText
>put " " & char 4 to 6 of pText after fText
>  end if
>  if the number of chars in pText > 6 then
>put "-" & char 7 to 10 of pText after fText
>  end if
> 
>  mobileControlSet "phoneNumber","text",fText
>  androidGoLastChar "phoneNumber",fText
>end if
>  end if
> end inputTextChanged
> 
> function numbersOnly pNum
>  //returns only the numbers in pNum
>  put "" into fNum
>  repeat for each char c in pNum
>if isNumber(c) then
>  put c after fNum
>end if
>  end repeat
> 
>  return fNum
> end numbersOnly
> 
> on androidGoLastChar mControl,xText
>  if ("Android" is in the platform) then
>mobileControlSet mControl,"selectedRange",(the number of chars in
> xText+1,0)
>  end if
> end androidGoLastChar
> 
> 
> Thank you!
> 
> Dan Friedman
> CEO, ClearVision Technologies, LLC
> Voice: 909/484-2052
> http://www.clearvisiontech.com
> 
> 
> From: use-livecode  on behalf of
> panagiotis merakos via use-livecode 
> Date: Tuesday, March 5, 2024 at 9:45 AM
> To: How to use LiveCode 
> Cc: panagiotis merakos 
> Subject: Re: Cursor Placement in MobileControl Hello Dan,
> 
> I take it you are formatting the text in inputTextChanged?
> 
> Unfortunately yes, on Android calling
> 
> mobileControlSet "phoneNumber","text", pText
> 
> puts the cursor in the beginning of the text:
> 
> https://quality.livecode.com/show_bug.cgi?id=24055
> 
> RE using the selectedRange with mobile native controls, I think this
> property is supported only on multiline input fields. So I suppose you could
> make the fields to be multiline and give it a try.
> 
> Kind regards,
> Panos
> --
> 
> On Tue, 5 Mar 2024 at 18:53, Dan Friedman via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> 
>> I am trying to create a field on mobile (iOS and Android) that will 
>> format a phone number as your type (client request).  I am able to do 
>> this on iOS as the command: mobileControlSet 
>> "phoneNumber","text",pText puts the cursor AFTER the text so the user 
>> can simply continue typing.  But, on Android, the cursor is placed at the
> beginning of the text after the
>> mobileControlSet command is called.   Is there a way to set the position
> of
>> the cursor on a native mobile text field?
>> 
>> I did notice that the Android Native Field widget has a selectedRange 
>> property.  Can I use this property on a native Android control?  And, 
>> can I set the selectedRange to "16,15" to set the cursor location, not 
>> select text?
>> 
>> Why not just use the Android Native Field widget, you ask?   I will if I
>> have to. but I prefer to use the native control as it is 
>> cross-platform and I don't need to case out for which platform we're 
>> on.  You would need to create the control and hide the widget for iOS 
>> and show the widget for Android.  I'll also have to case out the 
>> setting  and getting of the text as they have different methods.  I'll do
> this if I have to, but I'd rather
>> have a single code set and not have to manage/update separate methods.   I
>> would use the standard LC field, but client wants the standard
>> hold->popupMenu->paste command to work.
>> 
>> Any thoughts or ideas?
>> 
>> -Dan
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit 

RE: Cursor Placement in MobileControl

2024-03-06 Thread Ralph DiMola via use-livecode
Dan,

Nice... thanks!

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of Dan Friedman via use-livecode
Sent: Wednesday, March 06, 2024 11:15 AM
To: How to use LiveCode
Cc: Dan Friedman
Subject: Re: Cursor Placement in MobileControl

Panos,

Thank you for the suggestion!   That worked out well!   For anyone
interested, here's the snippet for formatting a phone number as you type in
a mobile native field control:

//this assumes that the mobileControl type for Android is "multiline" and
the mobileSetKeyboardType has been set to "email"

on inputTextChanged
  put mobileControlTarget() into pField
  put mobileControlGet(pField,"text") into pText

  if pField = "phoneNumber" then
put "" into fText
put numbersOnly(pText) into pText

if char 1 of pText = "1" then
  put "" into fText
  mobileControlSet "phoneNumber","text",fText
  androidGoLastChar "phoneNumber",fText
  put fText into dataEntered["phone"]
  exit inputTextChanged
end if

if the number of chars in pText < 4 then
  put pText into fText
  mobileControlSet "phoneNumber","text",fText
  androidGoLastChar "phoneNumber",fText
else
  if (the number of chars in pText > 3) then
put "(" & char 1 to 3 of pText & ")" into char 1 to 3 of fText
put " " & char 4 to 6 of pText after fText
  end if
  if the number of chars in pText > 6 then
put "-" & char 7 to 10 of pText after fText
  end if

  mobileControlSet "phoneNumber","text",fText
  androidGoLastChar "phoneNumber",fText
end if
  end if
end inputTextChanged

function numbersOnly pNum
  //returns only the numbers in pNum
  put "" into fNum
  repeat for each char c in pNum
if isNumber(c) then
  put c after fNum
end if
  end repeat

  return fNum
end numbersOnly

on androidGoLastChar mControl,xText
  if ("Android" is in the platform) then
mobileControlSet mControl,"selectedRange",(the number of chars in
xText+1,0)
  end if
end androidGoLastChar


Thank you!

Dan Friedman
CEO, ClearVision Technologies, LLC
Voice: 909/484-2052
http://www.clearvisiontech.com


From: use-livecode  on behalf of
panagiotis merakos via use-livecode 
Date: Tuesday, March 5, 2024 at 9:45 AM
To: How to use LiveCode 
Cc: panagiotis merakos 
Subject: Re: Cursor Placement in MobileControl Hello Dan,

I take it you are formatting the text in inputTextChanged?

Unfortunately yes, on Android calling

mobileControlSet "phoneNumber","text", pText

puts the cursor in the beginning of the text:

https://quality.livecode.com/show_bug.cgi?id=24055

RE using the selectedRange with mobile native controls, I think this
property is supported only on multiline input fields. So I suppose you could
make the fields to be multiline and give it a try.

Kind regards,
Panos
--

On Tue, 5 Mar 2024 at 18:53, Dan Friedman via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I am trying to create a field on mobile (iOS and Android) that will 
> format a phone number as your type (client request).  I am able to do 
> this on iOS as the command: mobileControlSet 
> "phoneNumber","text",pText puts the cursor AFTER the text so the user 
> can simply continue typing.  But, on Android, the cursor is placed at the
beginning of the text after the
> mobileControlSet command is called.   Is there a way to set the position
of
> the cursor on a native mobile text field?
>
> I did notice that the Android Native Field widget has a selectedRange 
> property.  Can I use this property on a native Android control?  And, 
> can I set the selectedRange to "16,15" to set the cursor location, not 
> select text?
>
> Why not just use the Android Native Field widget, you ask?   I will if I
> have to. but I prefer to use the native control as it is 
> cross-platform and I don't need to case out for which platform we're 
> on.  You would need to create the control and hide the widget for iOS 
> and show the widget for Android.  I'll also have to case out the 
> setting  and getting of the text as they have different methods.  I'll do
this if I have to, but I'd rather
> have a single code set and not have to manage/update separate methods.   I
> would use the standard LC field, but client wants the standard
> hold->popupMenu->paste command to work.
>
> Any thoughts or ideas?
>
> -Dan
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Cursor Placement in MobileControl

2024-03-06 Thread Dan Friedman via use-livecode
Panos,

Thank you for the suggestion!   That worked out well!   For anyone interested, 
here’s the snippet for formatting a phone number as you type in a mobile native 
field control:

//this assumes that the mobileControl type for Android is “multiline” and the 
mobileSetKeyboardType has been set to “email”

on inputTextChanged
  put mobileControlTarget() into pField
  put mobileControlGet(pField,"text") into pText

  if pField = "phoneNumber" then
put "" into fText
put numbersOnly(pText) into pText

if char 1 of pText = "1" then
  put "" into fText
  mobileControlSet "phoneNumber","text",fText
  androidGoLastChar "phoneNumber",fText
  put fText into dataEntered["phone"]
  exit inputTextChanged
end if

if the number of chars in pText < 4 then
  put pText into fText
  mobileControlSet "phoneNumber","text",fText
  androidGoLastChar "phoneNumber",fText
else
  if (the number of chars in pText > 3) then
put "(" & char 1 to 3 of pText & ")" into char 1 to 3 of fText
put " " & char 4 to 6 of pText after fText
  end if
  if the number of chars in pText > 6 then
put "-" & char 7 to 10 of pText after fText
  end if

  mobileControlSet "phoneNumber","text",fText
  androidGoLastChar "phoneNumber",fText
end if
  end if
end inputTextChanged

function numbersOnly pNum
  //returns only the numbers in pNum
  put "" into fNum
  repeat for each char c in pNum
if isNumber(c) then
  put c after fNum
end if
  end repeat

  return fNum
end numbersOnly

on androidGoLastChar mControl,xText
  if ("Android" is in the platform) then
mobileControlSet mControl,"selectedRange",(the number of chars in xText+1,0)
  end if
end androidGoLastChar


Thank you!

Dan Friedman
CEO, ClearVision Technologies, LLC
Voice: 909/484-2052
http://www.clearvisiontech.com


From: use-livecode  on behalf of 
panagiotis merakos via use-livecode 
Date: Tuesday, March 5, 2024 at 9:45 AM
To: How to use LiveCode 
Cc: panagiotis merakos 
Subject: Re: Cursor Placement in MobileControl
Hello Dan,

I take it you are formatting the text in inputTextChanged?

Unfortunately yes, on Android calling

mobileControlSet "phoneNumber","text", pText

puts the cursor in the beginning of the text:

https://quality.livecode.com/show_bug.cgi?id=24055

RE using the selectedRange with mobile native controls, I think this
property is supported only on multiline input fields. So I suppose you
could make the fields to be multiline and give it a try.

Kind regards,
Panos
--

On Tue, 5 Mar 2024 at 18:53, Dan Friedman via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I am trying to create a field on mobile (iOS and Android) that will format
> a phone number as your type (client request).  I am able to do this on iOS
> as the command: mobileControlSet "phoneNumber","text",pText puts the cursor
> AFTER the text so the user can simply continue typing.  But, on Android,
> the cursor is placed at the beginning of the text after the
> mobileControlSet command is called.   Is there a way to set the position of
> the cursor on a native mobile text field?
>
> I did notice that the Android Native Field widget has a selectedRange
> property.  Can I use this property on a native Android control?  And, can I
> set the selectedRange to “16,15” to set the cursor location, not select
> text?
>
> Why not just use the Android Native Field widget, you ask?   I will if I
> have to… but I prefer to use the native control as it is cross-platform and
> I don’t need to case out for which platform we’re on.  You would need to
> create the control and hide the widget for iOS and show the widget for
> Android.  I’ll also have to case out the setting  and getting of the text
> as they have different methods.  I’ll do this if I have to, but I’d rather
> have a single code set and not have to manage/update separate methods.   I
> would use the standard LC field, but client wants the standard
> hold->popupMenu->paste command to work.
>
> Any thoughts or ideas?
>
> -Dan
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode