Changing the texture of a TextureButton when selected

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GiantIsopod
:warning: Old Version Published before Godot 3 was released.

I’ve created a menu for my game and I’m using TextureButtons for the different choices. I want the player to be able to select the button either by clicking on the buttons with their mouse or by using the arrow keys, and therefore would like the buttons to show a different sprite when being selected. So the button on the left would have the “selected” texture when the left arrow key was pressed, and the right button would have the texture when the right arrow key is pressed. I’ve tried using get_focused_texture, but either it doesn’t do what I want it to do or I just don’t understand how it works (either is possible).

A sample of my code from the Yes Button on the left:

if popupvisible == "true":
	if event.is_action_pressed("move_left"):
		yeshover = "true"
		nohover = "false"
		
if yeshover == "true":
	get_focused_texture()

Thank you ahead of time for any help.

:bust_in_silhouette: Reply From: zen3001

you can just try setting the no normal texture to something else based on a script
set_texture() would be the function for this, something like this:

if Input.is_action_just_pressed("arrow_down"):
     $button1.set_texture(load(res:"//unselected.png"))
     $button2.set_texture(load(res:"//selected.png"))