What is up with "lock Cursor"?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 2:30 pm

This derived from a thread about cursors. I almost never use the "cursor" property.

But I do not understand why, in a new stack with a single button, in the button script:

Code: Select all

on mouseUp
   set the cursor to watch
   lock cursor
end mouseUp
The cursor only is watch while within the rect of the button itself. It reverts to arrow if I move out of the button rect. If instead I place that handler in the card script, then the cursor is a watch unless I enter the rect of the button. It cannot be so, but this test seems to indicate that when one changes the cursor, even if locked, it only retains its new form while within the rect of the initial object it was made.

I know so little of LC. :(

Craig

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

Re: What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 2:43 pm

It seems that changing the cursor is meant for running handlers, not just general cursor "styles".

But is there no way to simply have ones own cursor for general use?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9445
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: What is up with "lock Cursor"?

Post by richmond62 » Wed May 08, 2024 2:57 pm

Dunno: this works:

Code: Select all

on mouseUp
   set the cursor to 1003
   set the lockCursor to true
end mouseUp
-
Screenshot 2024-05-08 at 16.53.44.jpg
-
Clicking on the 'Paw', and away you go.
Attachments
CURSES.livecode.zip
Stack.
(7.97 KiB) Downloaded 6 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9445
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: What is up with "lock Cursor"?

Post by richmond62 » Wed May 08, 2024 3:01 pm

This works equally well with mouseEnter in the field script.
Attachments
CURSES_2.livecode.zip
Stack.
(8.01 KiB) Downloaded 9 times

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9850
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: What is up with "lock Cursor"?

Post by FourthWorld » Wed May 08, 2024 4:26 pm

dunbarx wrote:
Wed May 08, 2024 2:43 pm
It seems that changing the cursor is meant for running handlers, not just general cursor "styles".

But is there no way to simply have ones own cursor for general use?
See the defaultCursor global property.
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: 9731
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 5:07 pm

Richard.

Yep, that does it, thanks. Do not remember that at all. The dictionary ought to at least mention it in related "cursor" entries.

Craig

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

Re: What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 5:09 pm

Richmond.

Your "paw" changes as soon as the cursor leaves that image. That is what I wrote about initially.

Craig

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

Re: What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 5:16 pm

Richmond.

Just downloaded your second stack. Nope.

Again, the issue is that the cursor property cannot be used if one expects it to stick as the user navigates around the card. Richard really points out that, counterintuitively (at least to me) the "cursor" property, along with "lock cursor", is not the one I expected it to be. Rather, the "defaultCursor" is.

The "cursor" property works fine in certain cases, and on occasion I have used it this way. For example, in a button script:

Code: Select all

on mouseup
set the cursor to watch
lock Cursor --but not necessary
wait until the mouseClick
end mouseUp
The watch sticks because a handler is still running. This does not relate to a "general purpose" browser cursor.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9445
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: What is up with "lock Cursor"?

Post by richmond62 » Wed May 08, 2024 5:23 pm

Your "paw" changes as soon as the cursor leaves that image.
Well, over here, with LC 9.6.3 the 'paw' remains a paw across the card and those 'random' objects I sprinkled across the card.

Unfortunately the screen shot thingy in MacOS, even when 'show the pointer' is selected, does NOT show any cursor whatsoever.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9445
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: What is up with "lock Cursor"?

Post by richmond62 » Wed May 08, 2024 5:44 pm

Well that took a bit of fiddling around with some third-party software, but here we are:
-
Screenshot 2024-05-08 at 19.41.50.jpg
-
My 'paw' remains a paw through out the IDE.

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

Re: What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 6:46 pm

Richmond.

Are on linux? For me, only the global "defaultCursor" will allow me to keep whatever cursor I chose using the browse tool.

Surely the platform cannot have that sort of difference.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7257
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: What is up with "lock Cursor"?

Post by jacque » Wed May 08, 2024 6:55 pm

The cursor resets on idle if "lock cursor" is used. The defaultCursor replaces the arrow throughout -- usually. In a standalone you're pretty safe but in the IDE sometimes the LC cursor takes over again if you focus on an LC stack like the script editor and then go back to the mainstack.

There was a cursor bug for some time where lock cursor didn't work correctly, which was fixed recently. If you want a permanent fix without any scripting then you can replace the cursor images in the revCursors stack. Once that's done you'll have to drag the edited stack into any new version you download, replacing the default one.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9445
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: What is up with "lock Cursor"?

Post by richmond62 » Wed May 08, 2024 7:00 pm

Richmond.

Are on linux?
Not currently: MacOS.
you can replace the cursor images in the revCursors stack
I believe they have to be PDF images.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7257
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: What is up with "lock Cursor"?

Post by jacque » Wed May 08, 2024 9:21 pm

richmond62 wrote:
Wed May 08, 2024 7:00 pm
I believe they have to be PDF images.
No, just standard PNG, black and white, and a third color marked as transparent.

I should correct myself, the lock cursor command is supposed to last across handlers until it is unlocked, but a bug broke that until it was fixed recently, I think it was in LC 9.6.9.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: What is up with "lock Cursor"?

Post by dunbarx » Wed May 08, 2024 11:13 pm

Jacque.

I do not think so. My test stack has a button with:

Code: Select all

on mouseup
   set the cursor to watch
   lock cursor
   --wait until the mouseClick-- with messages
end mouseUp
Clicking on the button changes the cursor. But moving that cursor out of the rect of the button reverts to the standard arrow. I am in LC 9.6.9.

It feels like a bug to me, and the dictionary would agree:
Use the lock cursor command to make the cursor retain a specified appearance until you change it
That certainly implies to me that I must change it, not that it changes itself. If I uncomment the "wait" line, then the handler is still "running", and only another mouse click will release the watch.

Craig

Post Reply

Return to “Talking LiveCode”