Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impossible to change mouse cursor? #188

Open
moovida opened this issue Aug 16, 2018 · 3 comments
Open

impossible to change mouse cursor? #188

moovida opened this issue Aug 16, 2018 · 3 comments

Comments

@moovida
Copy link

moovida commented Aug 16, 2018

I am not sure if this is ok as issue, maybe more a feature request.

I need to change the cursor to crosshair to make the user pick informations on a tiles layer. Teh logic is handled ok by the onClick listener.

I have tried many css things at vaadin and component and window and whatever level, but I have not been able to change the mouse cursor in the map window.

Is there such a possibility?

(tested with vaadin 8)

@mstahv
Copy link
Owner

mstahv commented Sep 7, 2018

This is possible with some CSS today:

VAADIN/customstyles.css:

.v-leaflet.crosshair .leaflet-grab {
    cursor:crosshair;
}

Following annotation to your UI/map component:

@StyleSheet("vaadin://customstyles.css")

And in you Java code if you want to enable the crosshair (or whatever cursor) for the time your click listener is valid:

            map.addStyleName("crosshair");
            mapClickListener = map.addClickListener(e-> {
                    // do your thing

                    // remove listener and crosshair style name
                    mapClickListener.remove();
                    map.removeStyleName("crosshair");
                }
            });

That's pretty easy for me and those who are comfortable with CSS, but I guess a Java API would be nice for most v-leaflet users. Which cursors should be supported?

@aybond
Copy link

aybond commented Sep 7, 2018

Hello there.

@mstahv, it would be nice to support at least these type of cursors:

  • default
  • pointer
  • crosshair
  • grab
  • help

Regards.

@moovida
Copy link
Author

moovida commented Oct 2, 2018

I agree that a Java API would be amazing for the non-CSS champs as myself :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants