Almost forgot - make sure to connect _on_mouse_hover() to the ui element's mouse_entered signal!
Almost forgot - make sure to connect _on_mouse_hover() to the ui element's mouse_entered signal!
- Update ui element script again:
func _on_focused():
if parent_ui_ref.can_scroll:
parent_ui_ref._scroll_menu(self)
else:
parent_ui_ref.can_scroll = true # Makes can_scroll true again so it'll work with keyboard/gamepad.
Now, you should be good to go! Adjust to your liking 😀
- Update ui element script again:
func _on_focused():
if parent_ui_ref.can_scroll:
parent_ui_ref._scroll_menu(self)
else:
parent_ui_ref.can_scroll = true # Makes can_scroll true again so it'll work with keyboard/gamepad.
Now, you should be good to go! Adjust to your liking 😀
- Update ui element script:
Create function:
_on_mouse_hover():
parent_ui_ref.can_scroll = false
grab_focus()
This prevents the scroll effect when the mouse hovers over an element, but allows it from other sources.
- Update ui element script:
Create function:
_on_mouse_hover():
parent_ui_ref.can_scroll = false
grab_focus()
This prevents the scroll effect when the mouse hovers over an element, but allows it from other sources.
If your code grabs focus on mouse hover like ours does, and you don't want the mouse to be able to scroll the ui when it hovers, modify your code like this:
- Declare in parent ui script under scroll container ref:
var can_scroll = true
If your code grabs focus on mouse hover like ours does, and you don't want the mouse to be able to scroll the ui when it hovers, modify your code like this:
- Declare in parent ui script under scroll container ref:
var can_scroll = true
func _on_focus_entered():
parent_ui_ref._scroll_menu(self)
Also, remember to connect the button's "focus entered" signal to this _on_focus_entered() function.
func _on_focus_entered():
parent_ui_ref._scroll_menu(self)
Also, remember to connect the button's "focus entered" signal to this _on_focus_entered() function.
func _scroll_menu(control:Control):
if not control == null:
scroll_container.ensure_control_visible(control)
func _scroll_menu(control:Control):
if not control == null:
scroll_container.ensure_control_visible(control)
If you don’t have any yet, do this:
Copy/paste project folder before EVERY dev session. Keep one a week, more if you want.
You’ll thank yourself later!
If you don’t have any yet, do this:
Copy/paste project folder before EVERY dev session. Keep one a week, more if you want.
You’ll thank yourself later!
Ensure that the first line of the file has a “[“ in front of it, and that could help.
Ensure that the first line of the file has a “[“ in front of it, and that could help.
It may be corrupted by a bug with Godot that’ll be fixed in v4.3.
If you use an “onready preload” of your scene in any scripts, the engine may be corrupting the file there. Change these to “export PackedScene,” or “var path:String,” and try the previous step again.
It may be corrupted by a bug with Godot that’ll be fixed in v4.3.
If you use an “onready preload” of your scene in any scripts, the engine may be corrupting the file there. Change these to “export PackedScene,” or “var path:String,” and try the previous step again.