How to change WebControl's cursor?

In a WebApp, I have a WebImageViewer that when pressed will open an URL.
Screenshot 2022-11-21 at 00.38.29

I want to change the cursor of the control to a finger pointer.

Unfortunately the following in the Open event does not compile.

Me.Cursor = System.WebCursors.FingerPointer

What am I missing?

1 Like
  • I can confirm your results.
  • it looks like a documentation bug. If you use typeahead you will see there is a Cursor property as part of Style:

  • but it does not compile, either:

This code will compile:

WebImageViewer1.Opening
  dim x as integer = system.WebCursors.FingerPointer 
  me.style.Cursor = WebStyle.Cursors(x)

But seems to have no effect in the browser.

Submitted as #70938

Until the bugs are fixed you can add this line to the opening event of your WebImageViewer:

me.Style.Value("cursor") = "pointer"

pointer.2022-11-20 19_12_24

4 Likes

This is the correct way to specify the cursor. The values are in an enum, the name of the enum is system.WebCursors and the specific value for the enum is FingerPointer.

As to why it doesn’t work, I don’t have the answer, maybe the documentation can be of help. Lets see:

Sample code

The following code changes the pointer to a Finger Pointer when it is moved into the region of the control.

Me.Cursor = System.WebCursors.FingerPointer

In this example, Me is the WebImageViewer.

This works:

Me.Style.Cursor = WebStyle.Cursors.Pointer

It looks like the documentation needs an update.

1 Like

@MVP
i think xojo should generate the help/doc by extracting source code from a compiled example app.
in the same time the whole example could be linked in the documentation.

well again, in xojo 2023r4, same problem on a webcontainer shown event …

Me.Style.Cursor = System.WebCursors.FingerPointer

gives a

Type mismatch error.  Expected enum WebStyle.Cursors, but got Integer
Me.Style.Cursor = System.WebCursors.FingerPointer

Looks like you’re referencing the wrong enum.

Me.Style.Cursor = WebStyle.Cursors.Pointer

Original issue was probably fixed.

2 Likes

Anthony beat me. I was building an example to capture a GIF to show what works (the code Anthony posted).

I asked for the documentation to be updated but hasn’t been updated. Still a copy of the old docs: https://tracker.xojo.com/xojoinc/xojo/-/issues/70938#note_544266

So I don’t know what was fixed as the bug is a documentation bug/error.


Edit: well I think there is no FingerPointer available but Pointer is what I used for my example and it works:

Me.Style.Cursor = WebStyle.Cursors.Pointer
2 Likes

I just assumed something was fixed because his post made it seem like he had code that has stopped working even though it previously did. When I use WebStyles, I provide everything as strings because I assume — but haven’t tested — it’ll be faster than transforming the name and value(s).

Can you update your code as ‘fingerpointer’ doesn’t exist?

Here is the GIF I was working on showing that the code works:
ScreenRecording2024-02-16at6.09.20AM-ezgif.com-video-to-gif-converter

1 Like

In Short:
This Issue: https://tracker.xojo.com/xojoinc/xojo/-/issues/70938
Is marked as Bug Documentation Fixed
Screenshot 2024-02-16 at 6.16.49 AM
is closed.
Mentions this documentation page: WebCursors — Xojo documentation
that still have the wrong information as System.Webcursors.<whatever> doesn’t work, we need to use WebStyle.Cursors.<options available here>

I guess we need to open a new Issue with this specific information for the page to be updated. Is only Geoff able to update the documentation?

Why is it still closed? The thing to do is to re-open it.

Only Xojo or the OP can re-open it.

@Mike_D can you reopen the issue?

1 Like

The Hint/Help using the IDE works (if you place the mouse over cursor):

I think that is why I posted the code here back in Nov 2022. Sometimes you need to trust the IDE more than the documentation.


Edit: maybe @Jeremie_L can select one post with the working code as an answer to help others find the correct way to assign a cursor.