1

Suppose I have the following layout in GTK4: A vertical box in a window containing three child widgets:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ 
┃             Widget 1              ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃                                   ┃
┃                                   ┃
┃           Text View               ┃
┃                                   ┃
┃                                   ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃            Widget 2               ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ 

Where The Text View has the vexpand property set to true. I'm running into the following issue: when the text view gets large enough (by inserting lines), the box expands beyond the size of the window, pushing widget 2 out of visibility.

How can I make sure that the text view is limited in size by the parent box/window?

From what I can see/find, the solution is likely related to size requests, but I'm not sure how to dynamically calculate what the maximum size of the text view should be. (Note that I'm working on a way to add multiple text views which are vertically/horizontally separated, so Ideally I'd like a general solution where the widget can still resize when the conditions/layout change.

1 Answer 1

1

After some experimentation, I've found a solution. By placing the text view in a Gtk.Scrolled Window, the text view will scroll instead of growing beyond the limits of the window.

This is somewhat confusing to me, given that Gtk.TextView supposedly implements the Gtk.Scrollable interface, but I may be misunderstanding the purpose of this interface.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.