Update code for objects
This commit is contained in:
28
menuitem.go
28
menuitem.go
@@ -27,16 +27,15 @@ func NewMenuItem (text string) *MenuItem {
|
||||
}
|
||||
box.SetRole(tomo.R("objects", "MenuItem"))
|
||||
box.label.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
|
||||
box.SetLayout(layouts.Row { false, true })
|
||||
box.SetAttr(tomo.ALayout(layouts.Row { false, true }))
|
||||
|
||||
box.Add(box.icon)
|
||||
box.Add(box.label)
|
||||
|
||||
box.CatchDND(true)
|
||||
box.CatchMouse(true)
|
||||
|
||||
box.SetInputMask(true)
|
||||
box.OnButtonDown(box.handleButtonDown)
|
||||
box.OnButtonUp(box.handleButtonUp)
|
||||
box.OnKeyDown(box.handleKeyDown)
|
||||
box.OnKeyUp(box.handleKeyUp)
|
||||
box.SetFocusable(true)
|
||||
return box
|
||||
@@ -59,19 +58,26 @@ func (this *MenuItem) OnClick (callback func ()) event.Cookie {
|
||||
return this.on.click.Connect(callback)
|
||||
}
|
||||
|
||||
func (this *MenuItem) handleKeyUp (catch func(), key input.Key, numberPad bool) {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return }
|
||||
func (this *MenuItem) handleKeyDown (key input.Key, numberPad bool) bool {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *MenuItem) handleKeyUp (key input.Key, numberPad bool) bool {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return false }
|
||||
this.on.click.Broadcast()
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *MenuItem) handleButtonDown (catch func(), button input.Button) {
|
||||
catch()
|
||||
func (this *MenuItem) handleButtonDown (button input.Button) bool {
|
||||
if button != input.ButtonLeft { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *MenuItem) handleButtonUp (catch func(), button input.Button) {
|
||||
catch()
|
||||
if button != input.ButtonLeft { return }
|
||||
func (this *MenuItem) handleButtonUp (button input.Button) bool {
|
||||
if button != input.ButtonLeft { return false }
|
||||
if this.Window().MousePosition().In(this.Bounds()) {
|
||||
this.on.click.Broadcast()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user