Skip to content

Conversation

@mat007
Copy link
Contributor

@mat007 mat007 commented Aug 6, 2023

At the moment I believe it’s not possible to disable a list.
For instance doing this in the demo:

diff --git a/_examples/widget_demos/list/main.go b/_examples/widget_demos/list/main.go
index cb22494..6615104 100644
--- a/_examples/widget_demos/list/main.go
+++ b/_examples/widget_demos/list/main.go
@@ -93,8 +93,8 @@ func main() {
                        SelectedBackground:         color.NRGBA{R: 130, G: 130, B: 200, A: 255}, //Background color for the unfocused selected entry
                        SelectedFocusedBackground:  color.NRGBA{R: 130, G: 130, B: 170, A: 255}, //Background color for the focused selected entry
                        FocusedBackground:          color.NRGBA{R: 170, G: 170, B: 180, A: 255}, //Background color for the focused unselected entry
-                       DisabledUnselected:         color.NRGBA{100, 100, 100, 255},             //Foreground color for the disabled unselected entry
-                       DisabledSelected:           color.NRGBA{100, 100, 100, 255},             //Foreground color for the disabled selected entry
+                       DisabledUnselected:         color.NRGBA{120, 120, 120, 255},             //Foreground color for the disabled unselected entry
+                       DisabledSelected:           color.NRGBA{150, 150, 150, 255},             //Foreground color for the disabled selected entry
                        DisabledSelectedBackground: color.NRGBA{100, 100, 100, 255},             //Background color for the disabled selected entry
                }),
                //This required function returns the string displayed in the list
@@ -108,6 +108,7 @@ func main() {
                        fmt.Println("Is: ", args.Entry, " Was: ", args.PreviousEntry)
                }),
        )
+       list.GetWidget().Disabled = true

        //Add list to the root container
        rootContainer.AddChild(list)

doesn’t prevent from interacting with the list, select entries, etc…

Is there anything else needed? I tried to add a test in widget/list_test.go but it seems SetSelectedEntry works even when the list is disabled, probably by design.

@CLAassistant
Copy link

CLAassistant commented Aug 6, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@mcarpenter622 mcarpenter622 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works perfectly

@mcarpenter622 mcarpenter622 merged commit 37b421e into ebitenui:master Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants