Topic was automatically imported from the old Question2Answer platform.
Asked By
swipis
Old Version
Published before Godot 3 was released.
Hello!
Here is picture:
white background is a panel
other is buttons, label, and 2 progressbar’s
Im trying to check when mouse is on the panel, I made simple connection “mouse_enter” and “mouse_exit” and its kind’a working. If mouse is on white space its true (mouse is on the panel), but if mouse is on buttons, label, or progressbar return false (mouse is not on the panel). On other engines will return true on all children’s as well, so do I need to make “mouse_enter” to all children separately?
sorry for my english
thanks
Try unchecking “Stop mouse” on the children.
Bojidar Marinov | 2016-04-02 12:53
thanks, but by unchecking Stop Mouse still same , but check Ignore Mouse helped
Here is how I would solve the problem. I’m checking on every mouse exit event if the mouse is still inside the global rectangle of the control node. This will however fail if the Button is directly on the edge of the control nodes rectangle.
Un- checking the “Stop mouse” parameter of the children did not work as far as I can tell.
edit:
"replaced global_mouse_pos with get_tree().get_root().get_mouse_pos()"
extends Control
var mouse_inside = false
func _ready():
connect("mouse_enter",self,"in_")
connect("mouse_exit",self,"out_")
func out_():
if( get_global_rect().has_point( get_tree().get_root().get_mouse_pos() )):
print("mouse over button")
else:
print("mouse outside")
mouse_inside = false
func in_():
mouse_inside = true
Ignore Mouse worked just for label and progressbar’s, cannot ignore mouse on buttons