Multi-line GtkEntry or GtkTextView with GtkEntry's visual style

When creating a dialog with GTK3, is there a way to have a multi-line text input with the same visual style as the one from GtkEntry?

I haven’t found a way to make a GtkEntry with multi-line text input. The closest I got was putting a GtkTextView into a GtkScrolledWindow. This approach works technically, but the resulting widget does not have a clear visual frame and is missing the focus effect compared to GtkEntry.

Is there a way to apply the visual style of GtkEntryto GtkTextView or simply have a multi-line version of GtkEntry?

GtkEntry and GtkText are single-line by definition, so you won’t find any way to make those support multi-line input.

GtkTextView is the way to go. You probably want to look into the theme(s) you care about, see how they apply the desired effects on GtkEntry, then see if you can ‘lift and shift’ relevant CSS classes to your GtkTextView widget to get the same effects (ideally) or just replicate the CSS properties yourself (not so ideal, but may be needed).

1 Like

I share what was written by dboles. Additionally, you can put the scrolled window with GtkTextView into a GtkFrame and apply necessary border styles on the frame. Sometimes this provides a better result than styling borders directly by the key widget (= the one that does the job). Sometimes you need to style both. In any case, you would need some experimenting in order to get the expected effect (GtkInspector is a great help for this task), but I am pretty sure that this is possible.

2 Likes

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