ebitenui icon indicating copy to clipboard operation
ebitenui copied to clipboard

SIGSEGV panic when no image is specified for a Button

Open deckerrj opened this issue 2 years ago • 1 comments

Creating a button but not specifying a border image (widget.ButtonOpts.Image) creates a failure state when attempting to calculate PreferredSize. Since the button assumes Image.Idle will be non-nil.

It would be nice to not have to specify an Idle (or really any) NineImage for buttons without borders. For now I've set up a workaround using a transparent NewNineSliceColor.

deckerrj avatar Dec 26 '23 16:12 deckerrj

That work-around is the current way to do it. I agree that a runtime panic like that with no info is not exactly user friendly. I will look into handling this better.

mcarpenter622 avatar Dec 28 '23 03:12 mcarpenter622

With the current commit I have added better error messaging. I have kept ButtonOpts.Image required as I still think the user of the library should be intentional about how their buttons look (i.e using a transparent nineslice). But, now you will get a clearer error message indicating that the Idle image is required on startup.

I am going to close this ticket for now. Thank you!

https://github.com/ebitenui/ebitenui/commit/d5405bee081a9863a7ad91b4d27542ce8e69a1f5

mcarpenter622 avatar Mar 31 '24 16:03 mcarpenter622