Highlight row in treeview when hovering

I followed a blog post (link 1 and link 2) to add a highlight on rows in a ListBox while dragging. Now I want to do something similar with TreeView, but I don’t know how to do it.

I’m writing in Rust but I think a general approach would suffice as answer.

Is this hard to do, or did no one bother to respond? I take every help I can get.

All I wanna do is showing an indicator where a dragged item will land in a TreeView.

This is still relevant for me.

I don’t think treeviews are especially good with css support. However, in practice this worked for me in GTK 3 and 4:

treeview > *:hover {
    background-color: red;

Is this what you are looking for?

Not quite.
In the blog post it calculated if you hovered over the upper or the lower part over the item in the ListBox and based on that used another css which looked like this.

.row.drag-hover-top {
  border-top: 1px solid #4e9a06; 

The nice thing about this is you see where the dragged item will end up when released (given that there is a similiar css with a bottom border).

Now I’m searching a method to replicate a similar effect in a TreeView.

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