Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | radubolovan | |
Old Version | Published before Godot 3 was released. |
Hello,
I’m trying to make a dynamical resizing height dialog (the width will always be fixed). My control (dialog) has 1 background texture, a title (fixed maximum width), a text (fixed maximum width) and some buttons (OK, Cancel, Yes, No, etc).
Title type: Label
Text type: RichTextLabel
What I want to do:
-
Resize the background texture (the height) every time I set the title, the text and set the buttons:
var title_height = get_node("Title").get_line_height() var text_height = ? (I need this information) var total_height = top_margin + bottom_margin + dist_between_title_ and_text + dist_between_text_and_buttons + title_height + text_height var texture_height = total_height
. -
Rearrange the buttons’ positions by the size of the total height:
var buttons_pos_y = top_margin + dist_between_title_ and_text + dist_between_text_and_buttons + title_height + text_height
Please see in the above code what I need to find out (there’s a question mark).
I looked in RichTextLabel class and I couldn’t find nothing like get_text_size()
or get_text_width() & get_text_height()
P.S. Both (title and text) controls have Dynamic Font (.ttf) set.
Cheers,
Radu
Hi!
I know this is like a necrobump, but did you ever solve the problem?
I’m looking for a way to get_text_width()
too but so far haven’t found a solution.
mjtorn | 2018-04-09 10:53