I have a custom widget (an image viewer implemented as a GtkDrawingArea subclass) which has some keyboard bindings, so I need a focus indicator.
What’s the best way to do this? Should I use GtkOverlay to float some other widget over my drawing area and rely on that to draw the indicator? What would be the best widget to float on top?
So I’m currently drawing the focus indicator as a thin line just inside the window in my _snapshot() handler. It’d be much better if I could get gtk to draw it for me, of course!
Note that for testing, you can launch the gtk inspector with CtrlShiftI and paste the style above in the “CSS” tab.
That’s an easy way to visualize the outcome.
Sorry for the very late reply, it took me ages to get CSS drawing anything on my widget (the trick was to call gtk_widget_class_set_css_name(widget_class, "imagedisplay") in my class init, ooops).
Which kind-a looks a bit like the gtk focus indicator, but it won’t fade away after a while in the way that (for example) the focus ring on the scale widget will.
I tried that, but it stopped it working completely
Do you know if there’s something I need to call to make my GtkDrawingArea use the focus-visible state? I looked through the gtkscale sources but nothing jumped out at me (probably being dumb).
Ah! I was testing it by clicking in the drawing area, but nothing happens then. It DOES appear if I tab the focus in and out of the drawingarea, and it does vanish after a few seconds.