Problem or limitation
While working with OptionButton and MenuButton I like to add a small space between the button and the PopupMenu for aesthetic reasons and to follow my design system.
For now the workaround that I found requires creating a custom nodes that extend OptionButton and MenuButton that does the following:
class_name CustomOptionButton
extends OptionButton
@export var separation: int = 4
var popup: PopupMenu
func _ready() -> void:
popup = get_popup()
popup.about_to_popup.connect(_on_popup_about_to_open)
func _on_popup_about_to_open():
_adjust_popup.call_deferred()
func _adjust_popup():
# popup.position is read here, AFTER OptionButton has set it
popup.position = Vector2(popup.position.x, popup.position.y + separation)
which works but would be nicer to have it built-in.
Proposed improvement
Expose a constant in the OptionButton and MenuButton themes to define the separation between the button and the PopupMenu and use it when setting its position in the show_popup method.
Proposal review
Problem or limitation
While working with OptionButton and MenuButton I like to add a small space between the button and the PopupMenu for aesthetic reasons and to follow my design system.
For now the workaround that I found requires creating a custom nodes that extend OptionButton and MenuButton that does the following:
which works but would be nicer to have it built-in.
Proposed improvement
Expose a constant in the OptionButton and MenuButton themes to define the separation between the button and the PopupMenu and use it when setting its position in the show_popup method.
Proposal review