Search code examples
gtkgtk3

Draw a focus frame around a custom widget


GtkEntry has a nice rounded-corners frame around when it's focused. How do I get GTK to draw such a frame around my own widget (built on top of GtkDrawArea) when it is focused?

I skimmed through all descendants of GtkContainer but nothing does this. There is GtkFrame but it has another purpose and looks differently.


Solution

  • In the draw signal of your GtkDrawingArea, use gtk_render_focus() to draw the focus frame at the appropriate place.