No click event is generated when control is disabled.
This commit is contained in:
parent
1008b7b34b
commit
8236b65c06
@ -22,6 +22,7 @@ func EmptyEvent(fn EventFn) EventContextFn {
|
||||
type ControlBase struct {
|
||||
Bounds Rectangle
|
||||
|
||||
IsDisabled bool
|
||||
IsMouseOver bool
|
||||
|
||||
OnLeftMouseButtonClick EventContextFn
|
||||
@ -36,7 +37,7 @@ func (b *ControlBase) Handle(ctx *Context, event sdl.Event) bool {
|
||||
case *sdl.MouseMotionEvent:
|
||||
b.IsMouseOver = b.Bounds.IsPointInside(e.X, e.Y)
|
||||
case *sdl.MouseButtonEvent:
|
||||
if b.IsMouseOver && e.Button == sdl.BUTTON_LEFT && e.Type == sdl.MOUSEBUTTONDOWN {
|
||||
if !b.IsDisabled && b.IsMouseOver && e.Button == sdl.BUTTON_LEFT && e.Type == sdl.MOUSEBUTTONDOWN {
|
||||
return b.Invoke(ctx, b.OnLeftMouseButtonClick)
|
||||
}
|
||||
case *sdl.WindowEvent:
|
||||
|
@ -19,8 +19,7 @@ type IconButton struct {
|
||||
IconActive HoverEffect
|
||||
IconHover HoverEffect
|
||||
|
||||
IsActive bool
|
||||
IsDisabled bool
|
||||
IsActive bool
|
||||
}
|
||||
|
||||
func NewIconButton(icon string, onClick EventContextFn) *IconButton {
|
||||
|
Loading…
Reference in New Issue
Block a user