I have added and registered a ToolButton in the annotation toolbar. When this button is active, I’d like to change the cursor to a “crosshair”. How can I achieve that ? The Tool class has a “cursor” property but I don’t know how to change the value once the tool is registered.
The cursor property of the registerTool API should be enough to change the mouse cursor when the tool is active. I just tried the code below and it works for me on WebViewer 8.4:
Hi @dfelix , actually, it doesn’t work for me (it was due to a side effect…).
Here is how I registered the tool. I can see the tool in the header. But when I click on it, the pointer doesn’t shift to pointer (in this case)…I have the default cursor. I’m also on webviewer 8.4.1
@dfelix , here a short video.
No error in the console…
you can see that when I click on the tool (on the right), it is activated, but the cursor over the pdf is the default cursor. When I select a built in tool, I get the appropriate cursor, like the crosshair for the rubber tool.
PS : please note that as you can see in the code, I didn’t link the button to any specific action / annotation. I just created the buttonTool object + register it and added it to the header.
One idea : can the problem be due to a bad “time” of the tool creation. At the moment, I’m creating the tool when the “documentLoaded” event is triggered.
First of all, I was caught on a side effect too (I tried crosshair, but crosshair is actually the default cursor, so it didn’t work). Also, I did find that using the cursor option when registering a tool is not supposed to work. The actual way to change the cursor is to do it in the tool’s constructor.
I don’t have your tool code to show you the exact spot, but here is the tool code snippet that I managed to work (using a very different cursor this time around):
Hello @dfelix ,
I apologize for the late anwser, it seems that my previous answer was not sent…
Anyway, it works like a charm ! Thanks a lot for your answer and the example you provided !