does "set the screenmouseLoc" work on mobile?

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
bamakojeff
Posts: 33
Joined: Tue Dec 06, 2022 6:53 pm

does "set the screenmouseLoc" work on mobile?

Post by bamakojeff » Thu Mar 06, 2025 9:42 pm

I have a stack with a field "text" and a button. (The stack is attached.) The button has the following code in it:

Code: Select all

on mouseup
   local tTopLeft
   put the globalloc of the topleft of fld "text" into tTopLeft
   set itemdel to comma
   add the margins of fld "text" to item 1 of tTopLeft
   add (the effective textheight of fld "text" div 2) to item 2 of tTopLeft
   set the screenmouseLoc to tTopLeft
   wait 100 milliseconds with messages
   put tTopLeft && colon && the globalloc of the mouseLoc
end mouseup
On Windows, the mouse cursor is now at the first character position of the text in field "text" just like you would expect. The "put" statement at the end outputs two identical sets of coordinates.
184,136 : 184,136
But if I run the same same code on Android, the final "put" statement outputs the position of where the cursor was set, but second set of coordinates, where the cursor actually is, is always where I clicked on the button to run the code.
8,40 : 134,330
I've increased the wait time to ridiculous numbers; it doesn't matter. I've also tried running it from a handler where I don't touch the screen to run it, like "orientationChanged". In that case, when I rotate the device to trigger the handler, the mouseloc reports the last place I did touch the screen.

Can you set the screenMouseLoc on a mobile device? The docs don't say anything about this being read-only on mobile. What am I missing?
Attachments
screenMouseLoc.zip
(1.5 KiB) Downloaded 151 times

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: does "set the screenmouseLoc" work on mobile?

Post by FourthWorld » Fri Mar 07, 2025 8:46 am

Mobile devices have no mouse.

What are you trying to do?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: does "set the screenmouseLoc" work on mobile?

Post by dunbarx » Fri Mar 07, 2025 2:48 pm

Richard,

Might the OP want to find the loc of his finger? It sounds like it.

Craig

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: does "set the screenmouseLoc" work on mobile?

Post by SparkOut » Fri Mar 07, 2025 4:07 pm

I doubt it Craig. The OP mentions running the handler for messages other than button clicks, without touching the screen, and also the desired outcome seems to be to place the mouse cursor at the first char of the field.
On Android , there is no mouse pointer. The nearest might be to set the "insertion point" marker's location with focus and select options in the field, but it's not clear why this is something the OP wants to achieve.

bamakojeff
Posts: 33
Joined: Tue Dec 06, 2022 6:53 pm

Re: does "set the screenmouseLoc" work on mobile?

Post by bamakojeff » Fri Mar 07, 2025 5:09 pm

I'm trying to use Craig's very clever solution to an earlier problem of mine by using "set the screenMouseLoc" and then "scanning" along the text to find out when the background color changes.

viewtopic.php?f=8&t=38975&start=15#p228699

It works flawlessly on Desktop. But it doesn't work on Mobile. The docs claim that "screenMouseLoc" works on Mobile, but it seems you can only read it, not set it. Since the docs said nothing about it being read-only on mobile, I was hoping that livecode had a virtual" cursor which got placed there which I could use to "see" what was under it. But clearly not.

Setting the field to accept an insertion point and running "click at ...", however, may work just as well. Then I can get the selectedChunk from the field and "scan" along the text by incrementing the char in the field and checking the properties of the char X of fld "text".

As always, thank you all for pointing me a new promising direction. This forum is a gift!

Jeff

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: does "set the screenmouseLoc" work on mobile?

Post by FourthWorld » Fri Mar 07, 2025 7:31 pm

Does the selectedLoc function do what you need?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: does "set the screenmouseLoc" work on mobile?

Post by bn » Sun Mar 09, 2025 10:12 pm

You could try "clickLoc" instead of mouseLoc which works on mobile.
I do not know how "clickLoc" translates to global cooridinates and if you could then "click" at that location

Kind regards
Bernd

bamakojeff
Posts: 33
Joined: Tue Dec 06, 2022 6:53 pm

Re: does "set the screenmouseLoc" work on mobile?

Post by bamakojeff » Mon Mar 10, 2025 5:55 pm

I'm happy to report that "click" works fine on all platforms, at least for what I need. I get the top-left corner of the field, add in the margins, and I can click right at the first character of the first line. Once the program has "clicked" there, I can get all the information that I need from "mouseChar" and "mouseCharChunk".

So thanks again, all, for pointing me in the right direction.

Jeff

Post Reply