chip
July 8, 2024, 10:52pm
1
Godot Version
4.2 Stable
Question
Hi! I want to change the font of a button when hovered. I have set my buttons up in a
VBoxContainer. I have no idea of how to do this, I have tried with themes and code, but there is apparently no one else that has tried this, because I could not find any good sources for how to do this. I don’t even know if this is posibble.
Have started by setting up a script that recognizes when the mouse is over the button?
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
2301aa
On the game’s start screen, there are four buttons - New Game, Load
Game, Settings, and Exit. These buttons are placed on the left side
of the screen. My aim is to display a unique image on the right side
of the screen when the mouse hovers over each button. The image
should disappear when the mouse is moved away. Also, I want the
image …
chip
July 9, 2024, 6:42am
3
But do you know how to change the properties of the button? Everything I’ve looked at is for godot 3.
Are you trying to change the font face or something else like size or color?
chip
July 9, 2024, 2:19pm
5
I want to change the button-font to italic (for that I have two separate fonts) when hovered.
chip
July 9, 2024, 3:05pm
7
Thank you so much! This worked for me:
func _on_play_mouse_entered():
var fv = FontVariation.new()
fv.set_base_font(load("res://assets/fonts/Italic.otf"))
$MarginContainer/VBoxContainer/Play.add_theme_font_override("font", fv)
func _on_play_mouse_exited():
var fv = FontVariation.new()
fv.set_base_font(load("res://assets/fonts/Regular.otf"))
$MarginContainer/VBoxContainer/Play.add_theme_font_override("font", fv)
1 Like
system
Closed
August 8, 2024, 3:06pm
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.