Can anything block touchscreen buttons in Godot?

  • Thread starter Darkmisc
  • Start date
  • Tags
    godot
  • #1
Darkmisc
204
27
TL;DR Summary
I have a button that overlaps with a touchscreen button. When I press the button, it also presses the touchscreen button underneath. Can I stop this from happening?
Hi everyone

I have a button that overlaps with a touchscreen button. I want to be able to press the button without also pressing the touchscreen button. I can't use the .hide() function on the touchscreen button because I don't want to disable the whole touchscreen button.

Is there something I can use to block half of the touchscreen button (in the same way that you can block a button)?

If all else fails, I'm just going to make the button smaller or convert the touchscreen button to a regular button, but I'd rather not for aesthetic reasons. Thanks

1702447937868.png
 
Technology news on Phys.org
  • #2
I'm not familiar with Godot, but that seemed to be a z-index problem to me. But looking at Godot's documentation:
https://docs.godotengine.org/en/stable/classes/class_canvasitem.html#class-canvasitem-property-z-index said:
Note: Changing the Z index of a Control only affects the drawing order, not the order in which input events are handled. This can be useful to implement certain UI animations, e.g. a menu where hovered items are scaled and should overlap others.
This seems to indicate that it is the order in which you implement the input events that determines which button event is on top. Again, not an expert with Godot, but it seems to have something to do with InputMap.
 
  • Like
Likes Darkmisc

1. What causes touchscreen buttons in Godot to be blocked?

Touchscreen buttons in Godot can be blocked by various factors including overlapping UI elements, incorrect layering or z-index settings, and script errors that interfere with input processing. Additionally, visibility settings and the disabled state of buttons can prevent them from receiving touch inputs.

2. How can I debug issues with touchscreen buttons not working in Godot?

To debug touchscreen button issues in Godot, start by checking the button’s visibility and 'disabled' property settings. Ensure that the button is on the correct layer and that no other UI elements overlap it in a way that could block touch events. You can also use the Godot editor's debug tools to monitor events and print statements to check if touch events are being detected.

3. Can changing the z-index of a touchscreen button affect its functionality?

Yes, changing the z-index of a touchscreen button can affect its functionality. The z-index determines the stacking order of elements in the UI. If a button has a lower z-index than other overlapping elements, it might not receive touch inputs because those inputs are intercepted by the elements with higher z-index values.

4. How do I ensure that touchscreen buttons in Godot are responsive across different devices?

To ensure that touchscreen buttons in Godot are responsive across different devices, use scalable UI elements and consider different screen resolutions and aspect ratios. Godot’s Anchor and Margin system can be utilized to make UIs adaptable to various screen sizes. Additionally, testing on multiple devices or using a virtual device simulator can help identify and solve responsiveness issues.

5. What scripting techniques can be used to enhance the functionality of touchscreen buttons in Godot?

Scripting can greatly enhance the functionality of touchscreen buttons in Godot. You can use GDScript or VisualScript to handle events like '_on_Button_pressed' to execute actions. Scripts can also be used to dynamically enable or disable buttons, change their appearance, or modify their behavior based on game logic or user interactions, providing a more interactive and responsive user experience.

Similar threads

  • Programming and Computer Science
Replies
1
Views
699
  • Programming and Computer Science
Replies
1
Views
554
  • Programming and Computer Science
Replies
14
Views
3K
  • Programming and Computer Science
Replies
4
Views
388
  • Programming and Computer Science
Replies
4
Views
836
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
0
Views
518
  • Programming and Computer Science
Replies
9
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
341
Back
Top