Page 1 of 1

Curses

Posted: Mon Aug 01, 2022 7:16 pm
by richmond62
set the cursor to something

does NOT work in recent versions of LiveCode on MacOS:

https://forums.livecode.com/viewtopic.php?f=7&t=37192

Re: Curses

Posted: Tue Aug 02, 2022 3:41 am
by overclockedmind
richmond62 wrote: Mon Aug 01, 2022 7:16 pm set the cursor to something

does NOT work in recent versions of LiveCode on MacOS:

https://forums.livecode.com/viewtopic.php?f=7&t=37192
LCC (branded) 963, Linux Mint (Ubuntu 20.04 derivative,) the first two buttons don't do a thing, and the third (last) pops the script of the button as if there's something wrong with the script I'm supposed to see, and fix.

Re: Curses

Posted: Wed Aug 03, 2022 1:11 am
by OpenXTalkPaul
richmond62 wrote: Mon Aug 01, 2022 7:16 pm set the cursor to something

does NOT work in recent versions of LiveCode on MacOS:

https://forums.livecode.com/viewtopic.php?f=7&t=37192
Invisible Cursor works here, must lock the cursor before and/or (?) after changing the cursor:

Code: Select all

lock cursor; set the cursor to ""; wait 3 seconds; unlock cursor
or

Code: Select all

lock cursor; set the cursor to EMPTY; wait 3 seconds; unlock cursor
for invisible cursor for 3 seconds. Works for me on MacOS 12.4 & OXT 9.6.3.

I rarely use cursors lately, I used to use them frequently as a quick activity indicator ('set cursor to busy')

I do remember similar behaviors even going back to HyperCard days, and including with very own 'CursorDo XCMD' (circa 1994/95?, built with FutureBASIC, and includes an easter-egg: my special "New-F'ing-Jersey Cursor"). I always had to micro-manage the cursor with lock/unlock.

I added some 'lock cursor' AFTER your set cursors and it works as expected.
You got my cursor stuck as a tick or termite (or whatever that bug is, lol, good thing I had that line in my message box.

Here's modified version:
Accursed Cursors working.oxtstack
(4.58 KiB) Downloaded 98 times

Re: Curses

Posted: Wed Aug 03, 2022 10:17 am
by richmond62
Thanks for the help.

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. :?

Re: Curses

Posted: Wed Aug 03, 2022 12:17 pm
by OpenXTalkPaul
richmond62 wrote: Wed Aug 03, 2022 10:17 am Thanks for the help.

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. :?
Glad to help.
Eventually I'd like to get back to my music sequencing oriented coding, long ago I had 16x16px cursors set up for various musical note lengths, set via a palette of note buttons (Whole Note, Half, Quarter, Q-Triplet, Eighth, etc.) for use in 'step-writing' music ('playSentence' strings). Most recently I was messing with cursors a little bit while working on oxtTools, mostly that stack uses edit/browse and the 'grab' hand, I'd like to add in a few Photoshop type cursors there. We have the PS move layer-mover cursor (our current 'edit' mode cursor), do we have the circle-target-crosshair (for pixel-color sampler)?

Re: Curses

Posted: Wed Aug 03, 2022 12:33 pm
by OpenXTalkPaul
I added this stack to the web playground this morning and it doesn't work at all there, apparently there is zero cursor support in the Emscripten engine :-( ? We can probably set cursor via JavaScript, but that would likely have to be a custom library handler, unless that could be quickly patched in to the standalone-community.9.6.3.js engine file (which may be possible in certain cases).

Re: Curses

Posted: Wed Aug 03, 2022 12:52 pm
by OpenXTalkPaul
Adding the property <someTagElement element.style.cursor="move"> (for example) to DOM sets an HTML elements cursor within that element of the page, with javaScript you can do:

Code: Select all

document.body.style.cursor = "move";
Which works for setting "move" cursor while the mouse is within the outer page, but NOT within our Emscripten 'canvas' area, nor inside of web playground's little console-text area (which obviously we want text handling cursors there anyway).

According to this web site: http://www.javascripter.net/faq/stylesc.htm
virtually all web browsers include the following built-in cursors:
auto
move
no-drop
col-resize
all-scroll
pointer
not-allowed
row-resize
crosshair
progress
e-resize
ne-resize
default
text
n-resize
nw-resize
help
vertical-text
s-resize
se-resize
inherit
wait
w-resize
sw-resize

So I guess we just need to use JS to get the Emscripten Engine's canvas element by ID or Name, so that we can set the cursor within our web stack(s) canvas area (which is your effective screenRect as far as the Emscripten engine is concerned). At least for these browser built-in cursors, but will do more research to see if we can get custom-cursors working with JS.

Re: Curses

Posted: Wed Aug 03, 2022 10:45 pm
by OpenXTalkPaul
OpenXTalkPaul wrote: Wed Aug 03, 2022 12:52 pm So I guess we just need to use JS to get the Emscripten Engine's canvas element by ID or Name, so that we can set the cursor within our web stack(s) canvas area (which is your effective screenRect as far as the Emscripten engine is concerned). At least for these browser built-in cursors, but will do more research to see if we can get custom-cursors working with JS.
This puts our canvas element into the variable targetCanvas:

Code: Select all

var targetCanvas = document.getElementById("canvas").getElementsByClassName("emscripten")[0];
Probably the best way for a completely custom cursors with OXT on the web is to create a Base64 data URL from a .curs file, then we can that as the cursor-to-use URL.
.
..
...
....
This bit of JS works for changing the cursor, but then the Emscripten Engine crashes immediately after :(

Code: Select all

var canvas = document.getElementById('canvas');
canvas.setAttribute("style", "cursor: zoom-out");

Re: Curses

Posted: Thu Aug 04, 2022 1:16 am
by OpenXTalkPaul
OH! Of course so simple, this works for setting the cursor image in our Emscripten Engine

Code: Select all

document.getElementById("canvas").style.cursor = "zoom-in";
document.getElementById("canvas").style.cursor = "zoom-out";
document.getElementById("canvas").style.cursor = "arrow";
I tried a few things to get cursors working 'natively' to our xTalk engine (like adding revCursors.rev) but nothing worked.
But this works just fine. So the next thing would be to get custom cursors working, need to write a script that exports our xTalk 'native' cursor pixel maps into a base64 encoded data URL that we can then pass out to our JS instead of the standard web browser cursor names.

Re: Curses

Posted: Fri Aug 05, 2022 3:04 am
by OpenXTalkPaul
So I wasted a bunch of time trying to get custom cursors (png,gif,svg, URLs, data URI, etc.) to work within the Emscripten canvas, with absolutely no luck. It seems Emscripten uses a JS port of Simple Direct Media Layer (SDL, which I have mentioned as a library to possibly wrap with Builder FFI bindings).
So I need to find some Emscripten_SDL example code for changing the cursor in SDL (or rather the Emscripten port of it).
https://wiki.libsdl.org/SDL_CreateCursor

That's a back burner thing I think, web stacks can use the CSS cursors for now. I have more interesting fish to fry.