![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | haimat |
I would like to simulate a mouse click on to a texture button via GDScript.
So I tried the following function:
func simulate_btn_click(main_btn):
# main_btn.button is a TextureButton instance
var event = InputEventMouseButton.new()
event.position = main_btn.button.rect_global_position
event.button_index = BUTTON_LEFT
event.pressed = true
get_tree().input_event(event)
event.pressed = false
get_tree().input_event(event)
In this code main_btn.button
is a TextureButton
instance.
Then calling that function like this:
call_deferred("simulate_btn_click", button)
while processing a mouse click on to another button does nothing.
The texture (toggle) button does not change its texture, it’s logic is not being processed.
Any ideas what I am missing here?
What does
simulate
mean?
Bimi124 | 2020-12-18 09:22
Well, the user itself does not really click on the texture button.
I want to simulate that click, as if the user would have clicked on to the button.
haimat | 2020-12-18 09:47