package ui import ( rl "github.com/gen2brain/raylib-go/raylib" ) type DetectionType uint8 const ( OnClick DetectionType = iota OnHold ) type Button struct { WidthWeight float32 DisplayElement UIElement EventType DetectionType ButtonType rl.MouseButton clicked func(rl.MouseButton) bool } func (base *Button) Init(parent *Menu) { base.DisplayElement.Init(parent) if base.WidthWeight == 0 { base.WidthWeight = 1 } switch base.EventType { case OnClick: base.clicked = rl.IsMouseButtonReleased case OnHold: base.clicked = rl.IsMouseButtonDown } } func (base *Button) Destroy() { } func (base *Button) GetOccupationWeight() float32 { return base.WidthWeight } func (base *Button) Draw(position *rl.Rectangle) { base.DisplayElement.Draw(position) if base.clicked(base.ButtonType) { var mousePos = rl.GetMousePosition() if rl.CheckCollisionPointRec(mousePos, *position) { rl.TraceLog(rl.LogInfo, "xdx") } } }