Conversation
| } | ||
| } | ||
|
|
||
| func (o ButtonOptions) IgnoreTransparentPixels(ignoreTransparentPixels bool) ButtonOpt { |
There was a problem hiding this comment.
I am not in love with this name but cannot think of anything better.
Please add a comment to this method explaining it.
There was a problem hiding this comment.
I was having trouble naming it as well. If you have any better idea let me know. Maybe @quasilyte has some idea. Added some explanation, are you happy with it?
| WidgetOpts.CursorEnterHandler(func(args *WidgetCursorEnterEventArgs) { | ||
| if !b.widget.Disabled { | ||
| b.hovering = true | ||
| if b.mask == nil { |
There was a problem hiding this comment.
Will CursorEnter never run if we don't ignoreTransparentPixels?
There was a problem hiding this comment.
Actually not, the cursor enter (and exit) event is handled within cursor move. As the cursor enter is fired based on the rectangular shape of the widget, which does not know anything about the mask.
| b.pressing = true | ||
|
|
||
| b.PressedEvent.Fire(&ButtonPressedEventArgs{ | ||
| if b.hovering || b.mask == nil { |
There was a problem hiding this comment.
I dont think this will ever run if ignoreTranparentPixels is false
There was a problem hiding this comment.
Oh thought the same, but actually it does.
Here is how:
- Press & hold anywhere within the mask
- While pressed move the mouse cursor outside of the widget or even the game window, where mouse move event of the widget itself is not triggered
Closes #133
(Image *ButtonImage).Idle=> not optimal yetonMask(x, y)is every 4th byte of the pixels array is > 0. This is not configurableIt would be better in general if button would create an offscreen image with all elements (like text, graphic, etc..) instead of directly drawing to screen. This would simply allow to use the offscreen image as mask and ignore e.g. all transparent pixels (A = 0). If you favor this approach, we can work together to get this done.
If you do not feel comfortable with including this into button-widget directly, we could add another widget and make it optional to use.