• Godot Help
  • Atlas region of TextureButton only updates on Hover

Hi! So, I have a button displaying a region of an atlas, which I want to change at runtime through a toggle button. I use a setter for this: toggling changes property of TextureButton and its setter updates the region. For some reason, the region only updates when I hover my mouse over it, even though the setter runs immediately! (proven by a quick print statement). Could someone explain why this happens and how i can fix it? Cannot seem to find a similar problem reported online (maybe I'm not phrasing it right?)

MRE:

ParentControl has two TextureButton children: ToggleButton and AtlasTextureButton. ToggleButton has "toggle_mode" property on and the "toggled" signal connected to ParentControl's "_on_toggle_button_toggled()".
ToggleButton simply has the godot icon as texture_normal just to be able to click it, and AtlasTextureButton has a new AtlasTexture, with the Atlas set for the icon and the regions below (showing the upper or lower half of the icon on toggle of ToggleButton)

AtlasTextureButton.gd:

extends TextureButton

var toggle := false:
	set(value):
		if value:
			texture_normal.region = Rect2(0, 64, 128, 64)
		else:
			texture_normal.region = Rect2(0, 0, 128, 64)

ParentControl.gd:

extends Control


func _on_toggle_button_toggled(button_pressed): 
        $AtlasTextureButton.toggle = button_pressed

Thanks for the help!

UPDATE: Turns out there is a much simpler MRE: Only a TextureButton with an atlas and an _unhandeled_input call does the trick:

extends TextureButton

func _unhandled_input(event):
	if event.is_action_pressed("ui_accept"):
		print("accept")
		texture_normal.region = Rect2(0, 64, 128, 64)

Again, the print statement works everytime i press "Enter", but the texture only updates when I hover my mouse over the button