How do I use add_control_to_bottom_panel ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lowpolygon

According to doc I need a control so I have a scene with a Control node , under the control node I have a panel and a label with the text “Test”

In my script I have the following code:

extends EditorPlugin

var a_panel = preload("res://addons/add_bottom_menu/bottom_test.tscn")
var a_new_control :=

func _ready():
	a_new_control = a_panel.instance()
	add_control_to_bottom_panel(a_new_control,"My Plugin")

I did see a new button appears at the bottom menu with the name MY Plugin. But when I click on it ,nothing happens.
I searched google and found nothing. And doc is really not helping

I don’t know what should happen when you click the button,
but you should not need to call add_child again, it should already be called in add_control_to_bottom_panel

ATom 1 | 2020-01-09 09:42

ok, I took out the line . And I also noticed that that test panel did appear, but it shows up at the bottom of the screen where I can’t see. How would I go about setting the position?

lowpolygon | 2020-01-09 09:48

Should the position of the panel be above the button? Or, you did n’t actively set the panel position at all. If changing the position does not work, I think it should be limited by the layout?
But I don’t know much about layout. The most common way to set the position is to use transform.origin (relative to the position of the parent node)

ATom 1 | 2020-01-09 10:40

:bust_in_silhouette: Reply From: Dlean Jeans

Set rect_min_size.y.

Try this:

var editor_viewport = get_editor_interface().get_editor_viewport()
yield(get_tree(), 'idle_frame')
a_new_control.rect_min_size.y = editor_viewport.rect_size.y * 0.49

Thanks , this is exactly what I wanted. though I don’t understand it.

lowpolygon | 2020-01-10 01:33

Same, it must have something to do with how Godot UI system works.

Dlean Jeans | 2020-01-10 11:28

You could also set the Rect Min Size y for your top control in bottom_test.tscn.

a_new_control.rect_min_size.y = editor_viewport.rect_size.y * 0.49 means “set the height of my control to 49% of the total viewport height.”

idbrii | 2022-12-22 22:47