How to change mouse cursor?

Hi people :slight_smile: How are you? Hope all is ok.

Is there a way in Rack/draw process to switch the mouse icon? In windows, for example, I’m often using IDC_SIZENS or IDC_HAND modes, while hovering different stuff.

Any native way to do this in Rack? (cross-browser would be nice, since I’ll release stuff on each target platform).

Thanks again, as usual!

1 Like

https://www.glfw.org/docs/latest/input_guide.html#cursor_object Use responsibly.

3 Likes

Wouldn’t it be better to have this standardised in Rack, like hand cursor for draggable stuff, pencil for free drawing of waveshapes and so on (if there is really the need for it)? I do not want to take away anyone the freedom to design surfaces the way they want, but IMO it makes sense to unify such things/behaviors.

1 Like

If you have a feature request for Rack, you need to open a GitHub issue with your proposal.

1 Like

but please do so, it’s a great idea.

1 Like

Thanks, pretty straightforward. I’ve done this way, if someone else need:

void onHover(const event::Hover& e) override {
	OpaqueWidget::onHover(e);

	if (cursorBounded) {
		GLFWcursor *cursor;

		if (showHand) {
			cursor = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
		} else if (showVResize) {
			cursor = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
		}

		glfwSetCursor(APP->window->win, cursor);
	} else {
		glfwSetCursor(APP->window->win, NULL);
	}
}
void onLeave(const event::Leave& e) override {
	OpaqueWidget::onLeave(e);

	glfwSetCursor(APP->window->win, NULL);
}
1 Like

Why not use onEnter?

Because while “hovering” the plot, cursor will change according to what I’m hovering (point, lines, etc). So I need constantly to check what I’m hovering, and change the mouse icon accordly.