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 {
|
type ControlBase struct {
|
||||||
Bounds Rectangle
|
Bounds Rectangle
|
||||||
|
|
||||||
|
IsDisabled bool
|
||||||
IsMouseOver bool
|
IsMouseOver bool
|
||||||
|
|
||||||
OnLeftMouseButtonClick EventContextFn
|
OnLeftMouseButtonClick EventContextFn
|
||||||
@ -36,7 +37,7 @@ func (b *ControlBase) Handle(ctx *Context, event sdl.Event) bool {
|
|||||||
case *sdl.MouseMotionEvent:
|
case *sdl.MouseMotionEvent:
|
||||||
b.IsMouseOver = b.Bounds.IsPointInside(e.X, e.Y)
|
b.IsMouseOver = b.Bounds.IsPointInside(e.X, e.Y)
|
||||||
case *sdl.MouseButtonEvent:
|
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)
|
return b.Invoke(ctx, b.OnLeftMouseButtonClick)
|
||||||
}
|
}
|
||||||
case *sdl.WindowEvent:
|
case *sdl.WindowEvent:
|
||||||
|
@ -20,7 +20,6 @@ type IconButton struct {
|
|||||||
IconHover HoverEffect
|
IconHover HoverEffect
|
||||||
|
|
||||||
IsActive bool
|
IsActive bool
|
||||||
IsDisabled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIconButton(icon string, onClick EventContextFn) *IconButton {
|
func NewIconButton(icon string, onClick EventContextFn) *IconButton {
|
||||||
|
Loading…
Reference in New Issue
Block a user