How to click a texturebutton with script?
Asked Answered
A

2

0

Hi,
i have TextureButtons that i use with the mouse and i would like to trigger it with my keyboard.
i have that to begin with:

func _process(delta):
	if Input.is_action_just_pressed("dpad_left"):
		var left = get_node("../interface/UI/d_pad/hfpad/lbox/left")
		print("left")

it works fine but if i try some:
left.emit_signal("button_pressed")
or
left.is_pressed()=true
or whatever, it doesn't trigger my button, or maybe it does (i didn't put any function to it yet) but it doesn't change its texture as if pressed by the mouse and that's what i'm trying to do.

Can you tell me how to do it?
Thanks

Anatola answered 13/11, 2023 at 11:30 Comment(0)
P
0

Unsure what you're trying to achieve. A button will respond to control events (e.g. keyboard space, a controller face button) when it has focus. I guess what I'm trying to say is, keep navigation-like controls for navigation (that is, 'left' will move the focus around UI controls) and let buttons do what they've been programmed to do (when in focus, pressing 'A', for example, will press the button and your code receives a pressed signal).

Don't reinvent the wheel.

Pickwickian answered 13/11, 2023 at 11:56 Comment(0)
A
0

I guess you're right.
The mouse with buttons is good for a phone gameplay style in mind, i could just hide the buttons for a pc release that would use keyboard or gamepad.
I just wanted to see my button triggered when using the keyboard as a visual clue but it's kinda pointless for the game i suppose.

Nevermind, Thx

Anatola answered 13/11, 2023 at 12:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.