I have a TextArea in my application that actually takes no interactions from the user.
Is there a way to either
Remove the scrollbar entirely and let me handle what happens when the scrollbar would appear?
Use a different object to display text to the screen? I need to be able to append text, but I don't need it to be highlight-able or take any user input.
According to your needs, you need to use label.
If you need TextArea, to remove scrollBars, you can do the next :
Use lookupAll(java.lang.String selector) method to find scrollBars, and
call scrollBar.setOpacity(0.0) for each found scrollBar.
2a. Don't call setVisible(false), as visible property (I believe) is used to TextArea to control scrollBar visibility.
Related
A Button in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
Since the Button is in a Container, it is in control of its rect_size. The best we can do is specify a rect_min_size. There is no layout preset to have a Control depend on children Control. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size for the Button depending on the RichTextLabel. We can ask it for the height of its content with get_content_height. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield).
Apparently you don't want the Container to control the height of the Button. If that is the case, I think you can remove all the flags from size_flags_vertical.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container expand the width of the Button as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal.
Then, with the RichTextLabel properly set to take as much width of the parent Button as possible, you can read it height, and use it to set the height of the rect_min_size of the Button.
One more thing: you want to set the mouse filter of the RichTextLabel to Ignore or Pass, or it will prevent pressing the Button.
This is the code I came up with:
var b := Button.new()
b.size_flags_vertical = 0
b.size_flags_horizontal = SIZE_EXPAND_FILL
add_child(b)
var l := RichTextLabel.new()
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
l.set_anchors_and_margins_preset(Control.PRESET_WIDE)
l.text = "Some\nMultiline\nText"
b.add_child(l)
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
I'd like this to happen automatically depending on the amount of text inside
Sadly changing the text does not resize, nor change the minimum size of the RichTextLabel. And RichTextLabel does not have a "text changed" signal. Nor "bbcode text changed" signal. Furthermore, it might not be feasible to intercept these properties (see append_bbcode et.al). It is proabaly easier to do with a regular Label.
Anyway, what I'm going to suggest for this is to make a Control that wraps the RichTextLabel, offers whatever interface you actually need, and in any method where you change the text, afterwards, you do the equivalent of this:
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
(Godot 3.x)
Without using scripting, it is also possible to achieve the same goal by wrapping both nodes as sibilings within a container, for example a MarginContainer. Enable the RichTextLabel's fit_content_height property, which will result in the label expanding the container's area as much as necessary, which will in turn resize the Button.
Is there a simple way to hide all widgets (essentially hide the whole application)? There are multiple windows and widgets not attached to any window. I'm assuming it's some sort of modifier to the QApplication([]).
EDIT:
Better wording of my question thanks to #eyllanesc:
hide() method that prevents any window (or widget) from showing after using it and you also want the "show" method restore to the previous state.
A possible solution is to iterate over the top level widgets using QApplication::topLevelWidgets() and hide it:
for tl in QtWidgets.QApplication.topLevelWidgets():
tl.hide()
# or
# tl.close()
I have been trying to resolve this by myself but I can't find any answers. I need the text fields the combo box, etc., to display its own label, but I can't put it to work on a panel different from the FormPanel (in which all works great). I'm trying to display the labels for a text field on a VBoxLayout but I don't find the way to do it.
I need to work with a VBoxLayout because I need the widgets to position in the middle of the form after the window is maximized or minimized and this layout is the only one that proves to work. Is there another way to accomplish this?
Add another LayoutContainer and then set the panel to use FormLayout for example
LayoutContainer innerPanel = new LayoutContainer();
innerPanel.setLayout(new FormLayout());
Now it will work just like a form panel.
I am using LWUIT Library. I want to add same long information of project on AboutUS FORM. I'm using label but information become lost. If I am not using TextArea then what is another Solution?
My Another Question is,
In Login Form, what should be used TextField or TextArea?
Label is not good for showing long information. because its not allow to show multiple lines. Better you can use with TextArea and set the editable mode to false. If you dont want to use TextArea means just start the ticker on the Label.
Use TextField for login page.
I'm using a CMFCLinkCtrl in my custom dialog that inherits from CDialog. The CMFCLinkCtrl is set dynamically using data that is set by the user in another part of the application, so I have to handle long urls.
Is there a way to have the link control truncate what is displayed in the dialog and add an ellipse to the end? Currently the control is wrapping to the next line when it is too long to fit in the dialog or sees the "//" in the http://.
Static controls have an SS_ENDELLIPSIS style that does exactly what you want, but unfortunately this won't work with CMFCLinkCtrl which is derived from CButton. So you have two choices:
Use a static control with the SS_ENDELLIPSIS style, but you'll have to set the text colour and font yourself, and handle click events and open the URL manually.
Subclass CMFCLinkCtrl and add custom drawing code to add the ellipsis.
I think you're out of luck. You'll have to do what casablanca said or without subclassing truncate the text yourself (calculate the font size and link control size) and set it using SetWindowText.
You can easily resize the control to contain the entire text using SizeToContent, but I don't think this works for you.