Cursed or Blessed

All flavors welcome.
Forum rules
Be kind.
Post Reply
User avatar
richmond62
Posts: 2904
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Cursed or Blessed

Post by richmond62 »

In all probability somewhere between the two extremes. 8-)

Anyway, as someone "in a universe far, far away" was asking a question re bespoke cursors, and as I put about 15 minutes of my time into my contribution, I thought I would share it here as well.
-
Screenshot 2024-05-02 at 16.09.07.png
Screenshot 2024-05-02 at 16.09.07.png (62.1 KiB) Viewed 193 times
-
Script in the field:

Code: Select all

on mouseEnter
   set the lockCursor to true
   set the cursor to 1004
end mouseEnter 

on mouseLeave
   set the cursor to empty
   set the lockCursor to false
end mouseLeave
Having written that in LiveCode and checked that it worked, when I opened the stack in OXT Lite is behaved rather differently insofar as it made the OXT Lite cursor vanish completely!
Attachments
Cursor demo.oxtstack.zip
(3.16 KiB) Downloaded 6 times
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 1683
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Cursed or Blessed

Post by tperry2x »

Seems to work here, (resulting test video), but:
Rather than using 'Set the cursor to empty' - which (at least to my mind) would make the cursor blank, it might be better to use:

Code: Select all

Set the cursor to 0
I'm not sure why the LCC one works, and the the OXT one didn't for you (although it did for me in OXT) - however, according to the dictionary:
set the cursor to none: Hides the cursor
(so if 'empty' is also regarded as 'none', then this makes sense).

The dictionary also says you can use:
* none: Hides the cursor
* busy: Use repeatedly during a long handler
* watch: Use during a moderately long handler
* arrow: Use for select|selecting objects
* cross: Use for painting, drawing, or select|selecting a point or small area
* hand: Use for clicking hypertext links
* iBeam: Use for select|selecting text in a field
* plus: Use for select|selecting items such as spreadsheet cells
* help: Use for getting online help
It also says further down:
You can also set the cursor property to the ID of an image
Which is where my:

Code: Select all

Set the cursor to 0
suggestion comes from.

In that demo video, you'll also see an issue with using the mouseEnter and mouseLeave handlers to control cursors.
When the cursor passes over 'another object' inside the square, it counts as a mouseleave and sets the cursor back incorrectly. You could perhaps consider checking if the cursor is within a given rect instead.
User avatar
richmond62
Posts: 2904
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Cursed or Blessed

Post by richmond62 »

You could perhaps consider checking if the cursor is within a given rect instead.
This:

In the card script:

Code: Select all

on mouseMove
   if mouseLoc() is within the rect of fld "f1" then
      set the lockCursor to true
      set the cursor to 1004
   else
      set the cursor to 0
      set the lockCursor to false
   end if
end mouseMove
Throws a 'real bluey' insofar one has to wiggle the mouse around quite a bit to get the 'paw' to show, and exiting the field the cursor vanishes completely.

In the original stack, inwith LiveCode 963 the 'paw' shows inwith the field, and the cursor reverts to the normal Mac cursor on exiting the field.

That script has been lifted directly from my Devawriter Pro where I have used a bespoke cursor for text fields for at least 12 years without a hitch.

And my second attempt (see code above) also functions 100% in LC 963, but not in OXT Lite.
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 1683
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Cursed or Blessed

Post by tperry2x »

Your method works, (as does your code above in OXT lite for me), but you are constantly polling the mouse position, so it flickers like mad here - which sends no end of recurring messages to the card.

That's the problem with recurring checks like 'on mousemove' as it's doing it all the time.

Why not use something like this - better yet, set it on the field instead of the card?

Code: Select all

on mouseenter
   if not (the pendingmessages contains "tCheckMouse") then send tCheckMouse to me
end mouseenter

on mouseleave
   if not (the pendingmessages contains "tCheckMouse") then send tCheckMouse to me
end mouseleave

on tCheckMouse
   if the mouseloc is within the rect of fld "f1" then
      set the lockCursor to true
      set the cursor to the id of image "PAW.png"
   else
      set the cursor to 0
      set the lockCursor to false
   end if
end tCheckMouse
Also, after I did the video - I made a small change: instead of having a hardcoded ID for your image, I referenced the image name to get the ID.

Demo video here
mouse-revised.oxtstack
(3.29 KiB) Downloaded 7 times
Edit, I've added one which sets the default cursor here.
Edit 2: Topic along the same lines here (just to tie all these posts together).
User avatar
tperry2x
Posts: 1683
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Cursed or Blessed

Post by tperry2x »

richmond62 wrote: Thu May 02, 2024 1:45 pm That script has been lifted directly from my Devawriter Pro where I have used a bespoke cursor for text fields for at least 12 years without a hitch
Speaking of that, did you note in the demo vids of Devawriter I did, how much the window jumps around?
(demo on OSX 10.9), (demo on MacOS 10.15), (demo on MacOS 12)

I haven't looked into any of the script, as I was only testing for images appearing correctly. Is there something that reaffirms / repositions the stack window on opencard or something - as it seems to be applying to each and every time the card is changed.
User avatar
richmond62
Posts: 2904
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Cursed or Blessed

Post by richmond62 »

how much the window jumps around?
No, to be honest, as I did not have the opportunity to watch your "vid".

The jumping around is something to do with keeping the app's position on the screen, and now that you have pointed that out I really do need to get that to stop.

Thank you very much for pointing that out. 8-)
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 1683
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Cursed or Blessed

Post by tperry2x »

richmond62 wrote: Thu May 02, 2024 2:41 pm
how much the window jumps around?
No, to be honest, as I did not have the opportunity to watch your "vid".

The jumping around is something to do with keeping the app's position on the screen, and now that you have pointed that out I really do need to get that to stop.

Thank you very much for pointing that out. 8-)
No problem. Those videos also show that I was able to get the images to load without problems, which was the point of all that testing.
FourthWorld
Posts: 284
Joined: Sat Sep 11, 2021 4:37 pm
Contact:

Re: Cursed or Blessed

Post by FourthWorld »

Using the defaultCursor global property instead of lockCursor may provide a better UX for many types of apps, as it allows the cursor to change automatically to the I-beam when in text.
User avatar
OpenXTalkPaul
Posts: 1712
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Cursed or Blessed

Post by OpenXTalkPaul »

FourthWorld wrote: Thu May 02, 2024 3:54 pm Using the defaultCursor global property instead of lockCursor may provide a better UX for many types of apps, as it allows the cursor to change automatically to the I-beam when in text.
Setting defaultCursor has an effect of replacing the Run/'Browse' cursor in memory, the custom cursor can then change when mouse is over text as the Engine needs it to but then goes back to the cursor you've set when the mouse leaves that text area.
tperry2x wrote: Thu May 02, 2024 1:39 pm Seems to work here, (resulting test video), but:
Rather than using 'Set the cursor to empty' - which (at least to my mind) would make the cursor blank, it might be better to use:

Code: Select all

Set the cursor to 0
I'm not sure why the LCC one works, and the the OXT one didn't for you (although it did for me in OXT) - however, according to the dictionary:
set the cursor to none: Hides the cursor
(so if 'empty' is also regarded as 'none', then this makes sense).

The dictionary also says you can use:
* none: Hides the cursor
* busy: Use repeatedly during a long handler
* watch: Use during a moderately long handler
* arrow: Use for select|selecting objects
* cross: Use for painting, drawing, or select|selecting a point or small area
* hand: Use for clicking hypertext links
* iBeam: Use for select|selecting text in a field
* plus: Use for select|selecting items such as spreadsheet cells
* help: Use for getting online help
It also says further down:
You can also set the cursor property to the ID of an image
Which is where my:

Code: Select all

Set the cursor to 0
suggestion comes from.

In that demo video, you'll also see an issue with using the mouseEnter and mouseLeave handlers to control cursors.
When the cursor passes over 'another object' inside the square, it counts as a mouseleave and sets the cursor back incorrectly. You could perhaps consider checking if the cursor is within a given rect instead.
There's no need for different threads about the same 'cursors' topic, I wish these discussions could organize themselves, but I guess it's all interconnected to some degree. I try to use search to find the topics. But I know my stream of consciousness dumping jumps around a lot, one topic will often inspire thoughts about some loosely related topic. That's not necessarily a bad thing.

Anyway, I think Richmond had his cursor locking coming before his setting the cursor, which is the opposite of what you'd want. You set the cursor and THEN lock it so that it doesn't change back to the defaultCursor when the handler exits.

Hiding the cursor (set to 0, or empty, or 'none' which is a constant with numeric value of 0) doesn't really work well when I just tested those, the cursor hides but reappears flickering back and forth between hidden and visible as the mouse is moved. I think I remember it working properly to hide cursor (sans-flicker) in the past but maybe I'm wrong. I haven't attempted a 'kiosk' or presentation/slideshow sort of thing in a long time.

...
Stream of consciousness dump:

I wonder if we can't add more to the base set of cursors that are available to with additional global constants,
which is what the cursor names are. The 'busy' constant contains a list of number 16 to 23 then I guess?

Code: Select all

put iBeam + 1 -- = result of 9
The fact that the keywords are actually numeric constants really tripped me up when I had a Widget posting virtual keyDown/Up messages back to the engine from my Alpha-Numeric OnScreenKeyboard widget, because it was somehow being evaluated as number when the widget would 'post 'keyDown" && "plus", the receiving handler in the widget script was recieving 'keyDown 13' (FYI 'post' is a bit like the Widget/Extension Builder keyword equivalent of 'send').

One additional cursor I'd like to have available a 'pentool' cursor that looks like the common vector drawing sort of cursor, not a pencil or a brush. Because currently the graphics tools all use the same cross cursor. I also want there to be two separate select cursors for when 'select grouped' is on or off. And also want some sort of cursor to indicate cloning/copying of some object (The Arrow with a Plus sign inside circle).

revCursors (or revMacCursors, or whatever) actually has cursors 1 - 40, including each frame of 'busy', and only 9 of them are named with a keyword. Really we can have an unlimited amount of cursors.

Code: Select all

on mouseDown pButtonNumber
   repeat with x = 1 to 40
      set the cursor to x
      lock cursor
      wait 0.5 second
      unlock cursor
   end repeat   
end mouseDown
Didn't 'wait' (the clock or hourglass cursor) also used to be an animated cursor like 'busy'? And the counting hand was one in HyperCard too. I think they all came as 'CURS' resources in HyperCard (or from the Macintosh Toolbox ROM).

Modern MacOS AppKit comes with 59 cursors (which does NOT including animated cursor frames).

Web browsers standardized on these cursor names:
[ auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | grab | grabbing | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out ]

Could use cursors assets from Linux World, Gimp, InkScape.
User avatar
OpenXTalkPaul
Posts: 1712
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Cursed or Blessed

Post by OpenXTalkPaul »

On macOS AppKit has application presentation modes for things like Kiosks/slideshows where the cursor can be truly hidden, along with the menubar and dock:

https://developer.apple.com/documentati ... ionoptions
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests