Hide cursor redux

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

jmk_phd
Posts: 216
Joined: Sat Apr 15, 2017 8:29 pm

Hide cursor redux

Post by jmk_phd » Mon Aug 01, 2022 7:13 pm

Back in 2011-12 there was an item in this forum ("Set the cursor...") reporting that "set cursor to none" failed to work in a standalone built for the then-current version of Windows.

When I began developing my current app in 2015 I never experienced any such problem in the IDE or Mac/Win standalones. But now -- when I thought that I was finally only a few days away from publishing that app -- I find that "set cursor to none" fails even in the IDE when running LC 9.6.7.

Surely such an obvious bug would've been caught and fixed in LC 9.6.8, but installed and tried it today. No such luck.

Although my code has has undergone lots of changes/improvements over the years -- thanks largely to forum members -- it's not a coding error: When I open and run the stack in LC 9.6.1, all is fine. So it's a bug in recent versions of LC.

Not yet tried creating standones using 9.6.7/8 -- on the tenuous assumption that if it works in the IDE, it works in the standalones, and vice versa.

I suppose that for now I could create the standalones using 9.6.1 -- after all, LC's implementation for Mac M1/M2 is still dubbed "experimental," so I'd rely on Rosetta 2 anyway. Suggestions offered back in 2011-12 -- e.g., create a transparent image as an alternative to "none" -- do not work.

Any better workaround for now?

jeff k

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Hide cursor redux

Post by richmond62 » Mon Aug 01, 2022 7:43 pm

I am not sure whether to curse you (or possibly 'cursor' you) or beat a path to your door
and bury you up to your neck in the flowers of your choice . . .

The result of your posting was to stimulate me to do extremely pedestrian stuff like this:

Code: Select all

on mouseUp
   set the cursor to hand
end mouseUp
and

Code: Select all

on mouseUp
   set the cursor to watch
end mouseUp
and to find that neither of these worked . . . MacOS 13 beta 2

So: thought I would 'take a walk on the wild side' and try this:

Code: Select all

on mouseUp
   set the cursor to 1005
end mouseUp
where 1005 is a 64 x 64 monochrome image I had imported into my stack.

So . . . at least on MacOS 13 the whole cursor thing is no good at all.
-
SShot 2022-08-01 at 21.41.16.png
-
The 'TransP' button is a desperate attempt to set the cursor to a rectangle set to 99% transparency as a way
of faking an invisible cursor.
Attachments
Accursed Cursors.livecode.zip
Stack.
(4.18 KiB) Downloaded 170 times

jmk_phd
Posts: 216
Joined: Sat Apr 15, 2017 8:29 pm

Re: Hide cursor redux

Post by jmk_phd » Mon Aug 01, 2022 8:10 pm

Thanks, Richmond, for confirming my own experience.

Apparently (at least in recent versions of the LC IDE) the "set cursor to [anything]" does not trigger the intended change.

BTW, I don't think that this has anything to do with the version of macOS used to run the LC IDE. Although I resort to a newer Mac running 10.15 when necessary, my experience is the same with the humbly orphaned 10.12 that I still employ for everyday work. So your trial using macOS 13 suggests that this has nothing to do with the macOS used to run the LC IDE.

jeff k

P.S. If you must, sling flowers rather than arrow cursors.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Hide cursor redux

Post by richmond62 » Mon Aug 01, 2022 8:54 pm

It would be interesting to know whether the situation is the same on Linux and Windows.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Hide cursor redux

Post by jacque » Tue Aug 02, 2022 9:03 pm

It works but you need to lock the cursor before setting it to something else. Otherwise the change is so fast it looks like nothing happened.

Code: Select all

lock cursor
set the cursor to none
And when you want to revert it:

Code: Select all

unlock cursor
Try this in the multi-line message box:

Code: Select all

lock cursor
set the cursor to 33
wait 3 seconds
unlock cursor
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmk_phd
Posts: 216
Joined: Sat Apr 15, 2017 8:29 pm

Re: Hide cursor redux

Post by jmk_phd » Tue Aug 02, 2022 11:49 pm

Jacque --

Thanks much for your reply. I have no reason to doubt what you say, but this wasn't my experience. Checking back to an earlier version of the stack, I did in fact call "lock cursor" followed by "set the cursor to none", which was still problematic.

I don't recommend this bit of voodoo to anyone else, but I've found that the following handler finally has worked for me (at least while still running old IDE LC 9.6.1 rather than 9.6.8):

Code: Select all

on switchCursorState pWhichState
   -- parameter is either 0=hide cursor, or 1=show cursor
   if pWhichState = 0 then -- hide cursor
      unlock cursor
      set the cursor to the ID of image "transcursor" of card 1 of stack "pix"
      lock cursor
   else if pWhichState = 1 then -- show cursor
      unlock cursor
      set the cursor to arrow
   end if
end switchCursorState
The image "transcursor" is a 16x16 px entirely transparent 32-bit png, imported via "Import as Control > Image File...". (I'd been put off initially by the LC dictionary, which states that a custom cursor image "*must* contain three colors: black, white, *and* a transparent color" -- emphasis added -- but at least in the IDE a solely transparent image seems to work fine. Perhaps just a grammar issue?)

Although the cursor must be hidden while the items of each subtest of the program are displayed, it's necessary to call this routine to redisplay the arrow cursor at the start of each subtest, so that this is available to click either the "Cancel" or (default) "Continue" button in the answer dialog displayed.

The odd thing was that when one hit the "Return" key to trigger the default "Continue" button, the cursor got hidden as intended, but when one *clicked* the "Continue" button itself using the arrow cursor, it did not. I'm willing to believe that I'd overlooked something in my coding, but inserting the "switchCursorState" handler also before each item is displayed seems a small price in clock cycles to ensure that the cursor remains hidden as intended.

jeff k

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Hide cursor redux

Post by jacque » Wed Aug 03, 2022 1:56 am

I was locking the cursor before changing it rather than after. I tested in 9.6.8. I'll try your handler later and see what happens.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Hide cursor redux

Post by PaulDaMacMan » Wed Aug 03, 2022 2:15 am

What Jacque said works for me on Mac20,1 10-Core Intel Core i9, macOS 12.4 (21F79) with Community v.9.6.3

This gives me an invisible cursor for the 3 second wait time:

Code: Select all

lock cursor; set the cursor to ""; wait 3 seconds; unlock cursor
-- or ---
lock cursor; set the cursor to EMPTY; wait 3 seconds; unlock cursor
-- works as well, instead of 'none'
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Re: Hide cursor redux

Post by richmond62 » Wed Aug 03, 2022 11:19 am

I am feeling like a "right prawn" right now as to a certain extent that is my own stupidity as in
my Devawriter Pro source stack I have a bespoke cursor, but I implemented that about 12 years ago
and then forgot how I did it.

stam
Posts: 3069
Joined: Sun Jun 04, 2006 9:39 pm

Re: Hide cursor redux

Post by stam » Wed Aug 03, 2022 12:07 pm

[quote=jmk_phd post_id=216804 time=1659480550 user_id=
The image "transcursor" is a 16x16 px entirely transparent 32-bit png, imported via "Import as Control > Image File...". (I'd been put off initially by the LC dictionary, which states that a custom cursor image "*must* contain three colors: black, white, *and* a transparent color" -- emphasis added -- but at least in the IDE a solely transparent image seems to work fine. Perhaps just a grammar issue?)
[/quote]

Don’t think there’s any error there. The “transparent Color” is just the alpha channel for transparency setting isn’t it?

jmk_phd
Posts: 216
Joined: Sat Apr 15, 2017 8:29 pm

Re: Hide cursor redux

Post by jmk_phd » Thu Aug 04, 2022 8:36 pm

stam --

My point was simply that when taken literally, the dictionary entry "Custom cursor images must contain three colors: black, white, and a transparent color" implies that *all* three elements -- a black pixel, a white pixel, and a transparent alpha channel -- must be included.

If the entry had read instead, "Custom cursor images must contain at least one of three colors: black, white, and/or a transparent color," then I wouldn't have messed with creating creating an image that included all three before discovering that only one was sufficient.

Programming instructions are so unforgiving of error that I've just learned to take these literally. :-)

jeff k

jmk_phd
Posts: 216
Joined: Sat Apr 15, 2017 8:29 pm

Re: Hide cursor redux

Post by jmk_phd » Thu Aug 04, 2022 8:44 pm

Obviously, I am overlooking something very simple.

Here's the situation: An answer dialog is displayed to announce the start of each new section of the test. When one presses the Return key to trigger the default "Continue" button, the command to hide (set to "none") the cursor works as intended. (The cursor needs to be hidden in order not to distract the user from the images presented on the screen.)

However, if one instead uses the mouse to click the default "Continue" dialog button, the cursor is *not* hidden. This is easily reproduced:

Create a new stack with a singe button, then enter the following into the button script:

Code: Select all

on mouseup
   answer "Begin new subtest?" with "Continue"
   if it is "Continue" then
      lock cursor
      set cursor to none
      wait 3 seconds
      unlock cursor
   end if
end mouseup
Press the Return key and the cursor disappears (briefly) as intended. But click the "Continue" button in the answer dialog and it does not.

I've tried (for example) inserting in various places a line to set the defaultStack to the mainStack and/or to relocate the cursor to a point within the rect of the stack, but neither strategy has worked. Any ideas? Thanks!

jeff k

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

Re: Hide cursor redux

Post by SparkOut » Thu Aug 04, 2022 9:37 pm

On Windows (11) with LC 9.6.7 the behaviour is the same for both return or mouse-click on the continue button in the dialog here, with the cursor hidden correctly and restored after the wait.
(I haven't got around to updating to 9.6.8 yet)

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

Re: Hide cursor redux

Post by bn » Thu Aug 04, 2022 11:06 pm

On a Mac I see the behavior Jeff describes.

However if I add a wait x with messages it works when clicking the dialog button and when hitting return

Code: Select all

on mouseup
   answer "Begin new subtest?" with "Continue"
   if it is "Continue" then
      wait 20 milliseconds with messages
      lock cursor
      set cursor to none
      wait 3 seconds
      unlock cursor
   end if
end mouseup
For me it works when waiting 5 milliseconds but not reliably with 0 milliseconds. I have set it in above example to an arbitrary 20 milliseconds.
The question is why it only works on a Mac when a "wait with x milliseconds with messages" is included.

Kind regards
Bernd

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Hide cursor redux

Post by jacque » Fri Aug 05, 2022 1:28 am

The question is why it only works on a Mac when a "wait with x milliseconds with messages" is included.
Different clock cycles maybe?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply