How do you make buttons only pressed while the mouse cursor is on it?

Sorry, I am VERY unfamiliar with control nodes, so I don’t really know how to use it, how to get the hitbox thing to be the same as the button etc


the code to handle inside or outside the touchscreenbutton, connect the signal from inspector dock

var is_inside_press:bool=false
func _on_control_mouse_entered():

func _on_control_mouse_exited():

since you have 2 buttons? then it will need 2 boolean in total

so do I have to make a script for each of the buttons? And actually, I have multiple other buttons, so do I need x amount of buttons, and x amount of scripts?

as you can see i didnt make any new script, just connect the signals of control to the current scene’s main script that also handle the touchscreenbutton inputs

so will my player character script work to put this stuff in?

i dont see why not, it’s just adding condition from signal emitted by controls to decide if movement input is valid or not

Ok, so I had an idea: to clarify, this game is going to have LOTS of buttons, possibly somewhere around 15-20 or so, not including clones of buttons (and there will be ALOT of clones), and I did come up with a (somewhat) simple solution; covering the buttons with invisible buttons with passby press turned on. Then if you tried to leave the button press zone, you would start pressing a button that wouldn’t do anything. Would this work effectively? Or would adding code for the buttons work best? And if that is the case, would I have to add code for EACH button, including clones?

Tried adding buttons around the button but it didn’t work.

Ok, so will the control method work if I have lots of buttons, and a lot of clones of buttons? Or will I have to find another way?

if there are a lot of touchscreenbuttons, i suggest to just make a scene of it and have a script for its own, so you put the touchscreenbutton’s scene on the level scene at editor
the input is_action_pressed’s checking will be detected from this new script of touchscreenbutton scene, also along with its own control child node code to detect if mouse/touch is outside the control area or not

when input is valid from touchscreenbutton script, you then trigger the movement code on player’s script code according to its touchscreen purpose
which will then need you to define the movement/action at instantiated touchscreenbutotn’s scene on level scene. this will need to export the variable or even callable to make it work
is this too advance?

1 Like

But I think when you add a scene to a scene, you can’t move the parts around, and I need to be able to move the buttons around level-to-level

you can if you make it as a child of the player node, if you meant by moving around scenes
just put the touchscreenbutton scene as a child of the player scene

wonder why you didnt use Buttons instead, why it has to be TouchScreenButtons out of many Control’s buttons

I wasn’t aware of regular buttons when I used touchscreen buttons, and they look easier to use, aside from this one problem.

Do you know of any other way to make the button deactivate when the mouse is off of it that would work for lots of buttons and clones of buttons?

deactivated as in can no longer accept any input once mouse exit the button texture?

No, I guess I should word it better: I just want my buttons to no longer perform their commands as long as the mouse isn’t in the clickable area, but the button can be pressed as many times as possible.

perform command as in when hold down inside area of button texture, it will move? and when outside any command will be canceled?

1 Like

Yeah pretty much I think.

this behavior is combination of button_down, button_up, mouse_enter and mouse_exit signaling

1 Like