GTK4 Cursor and CSS

I am updating my keyboard application from GTK3 to GTK4. I am experimenting with gesture input and for that I had a grid of buttons for the letter keys and an Overlay with a DrawingArea. When the user clicked and dragged the mouse, I painted the trail of the movement on the DrawingArea. On release of the mouse, the trail was removed.
Now since I am porting the application to GTK4 I questioned that approach and thought it would make sense to use a cursor for that. My idea was to change the cursor when the mouse is clicked to a blue dot and when it is moved, it is supposed to leave a trail that slowly fades. Ideally it looks like these pictures.
I tried using CSS to achieve this but I was unable to change the style of the cursor with it. Can the cursor be changed via CSS? I was only able to assign a cursor to a widget via the set_cursor_from_name() method (Iā€™m using the Rust bindings).

Thanks for all the work of GTK4 and especially on the new documentation :slight_smile:
I had such a hard time learning GTK with the old docs.

No, GTK is not using CSS for cursors. You can set a cursor on a widget using gtk_widget_set_cursor, and you can create cursors using gdk_cursor_new_from_name or gdk_cursor_new_from_texture


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.