Hide cursor redux
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Hide cursor redux
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
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
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Hide cursor redux
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:
and
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:
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.
- -
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.
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
Code: Select all
on mouseUp
set the cursor to watch
end mouseUp
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
So . . . at least on MacOS 13 the whole cursor thing is no good at all.
- -
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
Re: Hide cursor redux
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.
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.
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Hide cursor redux
It would be interesting to know whether the situation is the same on Linux and Windows.
Re: Hide cursor redux
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.
And when you want to revert it:
Try this in the multi-line message box:
Code: Select all
lock cursor
set the cursor to none
Code: Select all
unlock cursor
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
HyperActive Software | http://www.hyperactivesw.com
Re: Hide cursor redux
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.
:
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
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.

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
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
Re: Hide cursor redux
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
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Hide cursor redux
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:
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'
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Hide cursor redux
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.
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.
Re: Hide cursor redux
[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?
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?
Re: Hide cursor redux
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
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
Re: Hide cursor redux
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:
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
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
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
Re: Hide cursor redux
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)
(I haven't got around to updating to 9.6.8 yet)
Re: Hide cursor redux
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
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
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
The question is why it only works on a Mac when a "wait with x milliseconds with messages" is included.
Kind regards
Bernd
Re: Hide cursor redux
Different clock cycles maybe?The question is why it only works on a Mac when a "wait with x milliseconds with messages" is included.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com