![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | monsterousoperandi |
Trying to be able to toggle between modes with this button so that I can change it’s details (including which shortcut triggers it) depending on mode but it’s currently not working. I can set any details I want to in the mode function but the game is ignoring my attempts to set a button short cut.
onready var button_1 = TextureButton.new()
func set_button_mode( mode: int ) -> void :
#combat mode
if mode == 0 :
var button_key = InputEventKey.new()
button_key.set_scancode(KEY_Q)
button_1.set_shortcut( button_key )
func _ready() -> void:
set_button_mode(0)
Also I notice that when I set the key with the editor, it shows in the the tool tip. Does any one know if this behavior is automatic or if I need to manually set this with GDScript if I change it latter?
I found a way. if I build a shortcut in the editor, then save it, Then clear the short cut in the editor, I can load the saved file it into my button. It works but I’m not sure what the difference is??? I wish the documentation was clearer…
func set_button_mode( mode: int ) -> void :
#combat mode
if mode == 0 :
button_1.set_shortcut(load("res://UI/ButtonShortcuts/Q_KEY.tres"))
monsterousoperandi | 2022-10-15 22:19