From 86f7b376c8a5ff79a4884eac70dd5c17fc29a5dc Mon Sep 17 00:00:00 2001 From: gucio321 Date: Tue, 26 Nov 2024 20:12:24 +0100 Subject: [PATCH] widgets: add ID() method to the ComboWidget --- Widgets.go | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Widgets.go b/Widgets.go index 92fdf282..4ab0e832 100644 --- a/Widgets.go +++ b/Widgets.go @@ -205,6 +205,30 @@ func Combo(label, previewValue string, items []string, selected *int32) *ComboWi } } +// ID sets the interval id of combo. (overrides label). +func (c *ComboWidget) ID(id ID) *ComboWidget { + c.label = id + return c +} + +// Flags allows to set combo flags (see Flags.go). +func (c *ComboWidget) Flags(flags ComboFlags) *ComboWidget { + c.flags = flags + return c +} + +// Size sets combo's width. +func (c *ComboWidget) Size(width float32) *ComboWidget { + c.width = width + return c +} + +// OnChange sets callback when combo value gets changed. +func (c *ComboWidget) OnChange(onChange func()) *ComboWidget { + c.onChange = onChange + return c +} + // Build implements Widget interface. func (c *ComboWidget) Build() { if c.width > 0 { @@ -226,24 +250,6 @@ func (c *ComboWidget) Build() { } } -// Flags allows to set combo flags (see Flags.go). -func (c *ComboWidget) Flags(flags ComboFlags) *ComboWidget { - c.flags = flags - return c -} - -// Size sets combo's width. -func (c *ComboWidget) Size(width float32) *ComboWidget { - c.width = width - return c -} - -// OnChange sets callback when combo value gets changed. -func (c *ComboWidget) OnChange(onChange func()) *ComboWidget { - c.onChange = onChange - return c -} - var _ Widget = &ContextMenuWidget{} // ContextMenuWidget is a context menu on another widget. (e.g. right-click menu on button).