Retroidian Games
banner
retroidiangames.bsky.social
Retroidian Games
@retroidiangames.bsky.social
Currently developing Pudding Yeet 🍮
4d.)

Almost forgot - make sure to connect _on_mouse_hover() to the ui element's mouse_entered signal!
July 18, 2024 at 4:45 PM
4c.)

- 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 😀
July 18, 2024 at 4:41 PM
4b.)

- 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.
July 18, 2024 at 4:40 PM
4a.) Voila!

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
July 18, 2024 at 4:38 PM
3.) Ensure your UI elements have a script with a reference to the parent UI script. Create a script like:

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.
July 18, 2024 at 4:32 PM
2.) In your UI script, write a function like this:

func _scroll_menu(control:Control):
if not control == null:
scroll_container.ensure_control_visible(control)
July 18, 2024 at 4:26 PM
Use get_total_character_count() to find the amount of characters in your text, the value you’ll want to stop at when incrementing “Visible Characters.” Sure beats counting!!
July 18, 2024 at 4:22 PM
This spooky bug highlights the importance of version control! Always use something like Git (GitHub Desktop App is easy)!
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!
July 18, 2024 at 4:21 PM
If neither of these worked, you may have to double-check the scene file itself for missing “delimiters,” symbols like “[“ or “{“ that organize scene file info (“sub resource” and so on).
Ensure that the first line of the file has a “[“ in front of it, and that could help.
July 18, 2024 at 4:21 PM
No luck yet?
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.
July 18, 2024 at 4:21 PM