Cursor Placement in MobileControl

panagiotis merakos merakosp at
Tue Mar 5 12:43:42 EST 2024

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:

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,

On Tue, 5 Mar 2024 at 18:53, Dan Friedman via use-livecode <
use-livecode at> 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 at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

More information about the use-livecode mailing list