#Hey, so i wonder is there a signal that detects am i holding a button
1 messages · Page 1 of 1 (latest)
That's functionality you'll have to add yourself
Oh, thanks
The mouse_entered signal is essentially a hovered signal as when your mouse enters it is hovered. Assuming you rely on mouse interaction for button usage.
Add this script to any Control node and it will print pressed/released, and for Button derived classes there are signals for it button_up and button_down
extends Control
func _gui_input(event: InputEvent) -> void:
var mb: InputEventMouseButton = event as InputEventMouseButton
if not mb:
return
if mb.button_index == MOUSE_BUTTON_LEFT:
if mb.pressed:
print("pressed")
else:
print("released")
This is unrelated to their question they want a holding signal not a pressed state one.
By holding its like having a timer that triggers the holding method after some time ?
the button_down() signal built into BaseButton does what you need
This is the same unrelated answer i think ;P
A signal that says a button is being held down is unrelated to "Hey so I wonder is there a signal that detects am I holding a button?"
ok buddy.
you can replace the _gui_input() method with button_down and button_up signals if you want. this will emit the signal holding(true) after 0.5 second of holding the button and will emit holding(false) if it was holding it
extends Control
signal holding(pressed: bool)
var timer: Timer = Timer.new()
var is_holding: bool
func _init() -> void:
timer.one_shot = true
add_child(timer)
timer.timeout.connect(_on_timer_timeout)
func _on_timer_timeout():
is_holding = true
holding.emit(true)
func _gui_input(event: InputEvent) -> void:
var mb: InputEventMouseButton = event as InputEventMouseButton
if not mb:
return
if mb.button_index == MOUSE_BUTTON_LEFT:
if mb.pressed:
timer.start(0.5)
else:
if not timer.is_stopped():
timer.stop()
if is_holding:
is_holding = false
holding.emit(false)
Good lord, stop with that nonsense. There is a signal built in for their exact needs. They want to know if a button is held, the button_down signal provides exactly that.
I think me and you didn't read the message till the end, he already have said that he have found the signal for clicking here
Basically i want to find a signal that can detect if im holding a button. I only found ones that detects a click not holding
Notice that the signal I provided is not the clicked signal they tried?
It is a button_held signal from the BaseButton class. entirely different and exactly what they asked for.
it emits once you click the button and this is also what i suggested for him there and the same thing that you have told me that it's not what he is searching for, did you test the code i wrote ? or you see this ? For Button derived classes there are signals for it button_up and button_down
just lets all agree that we are trying to help here xD
Why in the world would you INVENT new code to do something the script has built in.
When you hear hooves think horses not zebras.
he already have found the method that you are trying to tell him about and i already have told him about it too, please read the messages again
@dim stump this is your function, the other person in this chat is providing nonsense to reinvent the wheel. I am exiting the discussion now.
just please test the button_down signal yourself and tell me what does it do
it detects clicking and this is the same thing i have told him previously and the same thing you have told me it's not releated and made me realize that he already knows about it here I only found ones that detects a click not holding
Please try to help and if you want to argue about this we can continue in #💬┃casual-conversations
pressed() is what they tried that detects clicking. button_down() is only for being held down. Please stop pinging me, and learn about what you're saying before you talk next time please. It does huge harm to others when you guess at stuff you don't know.
Pressed is not button down or button up, this script is unrelated, that was my point. You can't use an AI or whatever you did to provide a script that doesn't even use the information you gave above it.
After that you once again gave a complex script for a simple signal call.
Yes you gave the right signals, you didn't use them in your script.
That is the confusion you caused and the problem with what you've said. Hence why I provided only the signal for them which is what they asked for.
I have provided the same signal in my answers right before showing the script and have made it clear that it was intended to work with Control nodes, but you have been disrespectful and have spammed the chat with the same answer many times and i don't feel good about your behavior so I'm passing this to the <@&1235162294586048574>, We all are here to help and what you have been doing wasn't helpful at all.
Sorry you don't like being called out but you didn't use the proper signal in either script and caused undue confusion for a beginner. I was attempting to explain to you so you could learn why your answer wasn't what they wanted but alas you seem too arrogant to accept that.
I'll move on as I tried to do when I asked you to stop pinging me but for any moderation involved please consider what I've said. They gave an answer then heavily convoluted the OPs ability to understand it by providing unneeded scripts that don't use the functionality that was requested or mentioned.
Cheers
considering OP wanted to tell when a button is being held, then your solution of just telling them to use the button_down is incorrect or incomplete, as it will fire regardless of whether the button is clicked and released or clicked and held down. presumably OP wants to know if a button was held for a certain duration of time, which would require pairing the button_down signal with a Timer node
@ruby sorrel regardless of your opinion regarding solutions provided by others, which you are fully entitled to, this doesn't give you the right to belittle them by acting unnecessarily confrontational and calling them "nonsense". this behavior will come across as hostile and won't lead to anything productive
That's reasonable. I struggle with social norms due to being autistic but I understand that's not okay so I will work harder to not belittle people for my opinions.
I do genuinely just want to help people learn I guess my frustration just came out in an unhealthy way, I can see that now. I'll move on and learn from this. Cheers
thank you for understanding. as for @solemn shell , please also respect when people choose to exit a conversation or wish to not be pinged by replies anymore. this can be done by clicking the "@ ON" button when writing your reply. it will still link to the original message, but its author won't be pinged anymore
Thanks for explaining the situation, and sorry about the bing.