diff --git a/control.go b/control.go index c4b43d5..b7cf6f4 100644 --- a/control.go +++ b/control.go @@ -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: diff --git a/iconbutton.go b/iconbutton.go index 32703f6..71f3768 100644 --- a/iconbutton.go +++ b/iconbutton.go @@ -19,8 +19,7 @@ type IconButton struct { IconActive HoverEffect IconHover HoverEffect - IsActive bool - IsDisabled bool + IsActive bool } func NewIconButton(icon string, onClick EventContextFn) *IconButton {