How to make a textedit selectable?

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

I am working on a basic menu system and need a way to type in data. I have managed to make the textedits appear in the proper size and location, but they cannot be selected. I know it is displaying text correctly because I preset it with random text which shows.


for key in TheMap.keys():
	var lb = lbScene.instance()#create a label scene
	lb.text = key
	m.add_child(lb) #add to menu
	lb.rect_position[0] = (x/width) * i
	lb.rect_position[1] = 60 * p
	var tb = tbScene.instance()
	m.add_child(tb) # add to menu
	tb.rect_position[1] = (50 * p) + 24 # set y pos
	tb.rect_position[0] = (x/width) * i # set x pos
	i = i+1
	tb.text = ('fwjg;jbw;gbo')
	if (i >= width):
		i = 0
		p = p+1 #new row

If it helps at all, the textedits were selectable when I was using nested VBoxContainers and HBoxContainers for positioning, however they were always the minimum thickness no matter what I did. Any help is appreciated.

:bust_in_silhouette: Reply From: Zylann

First, check if your TextEdits are actually editable by checking the readonly property. Make sure it is false.

Next, make sure your clicks are reaching the TextEdit. To test that, play your game, and try to click on the TextEdit. If it doesn’t work, have a look in the debugger, the “Misc” tab: in this tab you can see which control you clicked last. For example, if the click ended up on a control which has no visuals (such as a container or a plain Control), make sure its mouse mode is set to Ignore, or get rid of it.

Note about containers: if you use VBoxContainer or HBoxContainer, the key to layout items inside them is to either give them a minimum_size, or check the expand flag in Size Flags (vertical or horizontal depending on the case) so the control will fill the area calculated by its container.

Thanks for the tip on VBoxContainer and HBoxContainer.

Ertain | 2019-01-09 19:27