Fix object code
This commit is contained in:
parent
dca3880a87
commit
c2245ec304
@ -36,11 +36,11 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti
|
|||||||
|
|
||||||
dialog := &Dialog { }
|
dialog := &Dialog { }
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
window, err := tomo.NewWindow(image.Rectangle { })
|
window, err := tomo.NewWindow(tomo.WindowKindNormal, image.Rectangle { })
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
dialog.Window = window
|
dialog.Window = window
|
||||||
} else {
|
} else {
|
||||||
window, err := parent.NewModal(image.Rectangle { })
|
window, err := parent.NewChild(tomo.WindowKindModal, image.Rectangle { })
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
dialog.Window = window
|
dialog.Window = window
|
||||||
}
|
}
|
||||||
@ -60,7 +60,9 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti
|
|||||||
|
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
if option, ok := option.(clickable); ok {
|
if option, ok := option.(clickable); ok {
|
||||||
option.OnClick(dialog.Close)
|
option.OnClick(func () {
|
||||||
|
dialog.Close()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog.controlRow = NewInnerContainer(layouts.ContractHorizontal, options...)
|
dialog.controlRow = NewInnerContainer(layouts.ContractHorizontal, options...)
|
||||||
|
4
menu.go
4
menu.go
@ -40,7 +40,7 @@ func newMenu (parent tomo.Window, bounds image.Rectangle, items ...tomo.Object)
|
|||||||
menu := &Menu { }
|
menu := &Menu { }
|
||||||
menu.bounds = bounds
|
menu.bounds = bounds
|
||||||
menu.parent = parent
|
menu.parent = parent
|
||||||
window, err := menu.parent.NewMenu(menu.bounds)
|
window, err := menu.parent.NewChild(tomo.WindowKindMenu, menu.bounds)
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
menu.Window = window
|
menu.Window = window
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ func (this *Menu) TearOff () {
|
|||||||
if this.parent == nil { return }
|
if this.parent == nil { return }
|
||||||
this.torn = true
|
this.torn = true
|
||||||
|
|
||||||
window, err := this.parent.NewChild(this.bounds)
|
window, err := this.parent.NewChild(tomo.WindowKindToolbar, this.bounds)
|
||||||
window.SetIcon(tomo.IconListChoose)
|
window.SetIcon(tomo.IconListChoose)
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
|
@ -172,14 +172,14 @@ func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
case input.KeyUp, input.KeyLeft:
|
case input.KeyUp, input.KeyLeft:
|
||||||
if modifiers.Alt {
|
if modifiers.Alt() {
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
} else {
|
} else {
|
||||||
this.scrollBy(this.StepSize())
|
this.scrollBy(this.StepSize())
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case input.KeyDown, input.KeyRight:
|
case input.KeyDown, input.KeyRight:
|
||||||
if modifiers.Alt {
|
if modifiers.Alt() {
|
||||||
this.SetValue(1)
|
this.SetValue(1)
|
||||||
} else {
|
} else {
|
||||||
this.scrollBy(-this.StepSize())
|
this.scrollBy(-this.StepSize())
|
||||||
@ -320,12 +320,13 @@ func (this *Scrollbar) newLinkCookie (subCookies ...event.Cookie) *scrollbarCook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *scrollbarCookie) Close () {
|
func (this *scrollbarCookie) Close () error {
|
||||||
for _, cookie := range this.subCookies {
|
for _, cookie := range this.subCookies {
|
||||||
cookie.Close()
|
cookie.Close()
|
||||||
}
|
}
|
||||||
this.owner.layout.linked = nil
|
this.owner.layout.linked = nil
|
||||||
this.owner.box.SetAttr(tomo.ALayout(this.owner.layout))
|
this.owner.box.SetAttr(tomo.ALayout(this.owner.layout))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type scrollbarLayout struct {
|
type scrollbarLayout struct {
|
||||||
|
@ -202,7 +202,7 @@ func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
vector := image.Point { }
|
vector := image.Point { }
|
||||||
switch key {
|
switch key {
|
||||||
case input.KeyPageUp:
|
case input.KeyPageUp:
|
||||||
if modifiers.Shift {
|
if modifiers.Shift() {
|
||||||
vector.X -= this.PageSize().X
|
vector.X -= this.PageSize().X
|
||||||
} else {
|
} else {
|
||||||
vector.Y -= this.PageSize().Y
|
vector.Y -= this.PageSize().Y
|
||||||
@ -210,7 +210,7 @@ func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
this.scrollBy(vector)
|
this.scrollBy(vector)
|
||||||
return true
|
return true
|
||||||
case input.KeyPageDown:
|
case input.KeyPageDown:
|
||||||
if modifiers.Shift {
|
if modifiers.Shift() {
|
||||||
vector.X += this.PageSize().X
|
vector.X += this.PageSize().X
|
||||||
} else {
|
} else {
|
||||||
vector.Y += this.PageSize().Y
|
vector.Y += this.PageSize().Y
|
||||||
@ -218,7 +218,7 @@ func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
this.scrollBy(vector)
|
this.scrollBy(vector)
|
||||||
return true
|
return true
|
||||||
case input.KeyUp:
|
case input.KeyUp:
|
||||||
if modifiers.Shift {
|
if modifiers.Shift() {
|
||||||
vector.X -= this.StepSize().X
|
vector.X -= this.StepSize().X
|
||||||
} else {
|
} else {
|
||||||
vector.Y -= this.StepSize().Y
|
vector.Y -= this.StepSize().Y
|
||||||
@ -226,7 +226,7 @@ func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
this.scrollBy(vector)
|
this.scrollBy(vector)
|
||||||
return true
|
return true
|
||||||
case input.KeyDown:
|
case input.KeyDown:
|
||||||
if modifiers.Shift {
|
if modifiers.Shift() {
|
||||||
vector.X += this.StepSize().X
|
vector.X += this.StepSize().X
|
||||||
} else {
|
} else {
|
||||||
vector.Y += this.StepSize().Y
|
vector.Y += this.StepSize().Y
|
||||||
@ -241,6 +241,8 @@ func (this *ScrollContainer) handleKeyUp (key input.Key, numpad bool) bool {
|
|||||||
switch key {
|
switch key {
|
||||||
case input.KeyPageUp: return true
|
case input.KeyPageUp: return true
|
||||||
case input.KeyPageDown: return true
|
case input.KeyPageDown: return true
|
||||||
|
case input.KeyUp: return true
|
||||||
|
case input.KeyDown: return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ func (this *Slider) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
case input.KeyUp, input.KeyLeft:
|
case input.KeyUp, input.KeyLeft:
|
||||||
if this.box.Window().Modifiers().Alt {
|
if this.box.Window().Modifiers().Alt() {
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() - increment)
|
this.SetValue(this.Value() - increment)
|
||||||
@ -135,7 +135,7 @@ func (this *Slider) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
this.on.valueChange.Broadcast()
|
this.on.valueChange.Broadcast()
|
||||||
return true
|
return true
|
||||||
case input.KeyDown, input.KeyRight:
|
case input.KeyDown, input.KeyRight:
|
||||||
if this.box.Window().Modifiers().Alt {
|
if this.box.Window().Modifiers().Alt() {
|
||||||
this.SetValue(1)
|
this.SetValue(1)
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() + increment)
|
this.SetValue(this.Value() + increment)
|
||||||
|
@ -90,9 +90,9 @@ func (this *Swatch) Choose () {
|
|||||||
var err error
|
var err error
|
||||||
var window tomo.Window
|
var window tomo.Window
|
||||||
if parent := this.box.Window(); parent != nil {
|
if parent := this.box.Window(); parent != nil {
|
||||||
window, err = parent.NewChild(image.Rectangle { })
|
window, err = parent.NewChild(tomo.WindowKindNormal, image.Rectangle { })
|
||||||
} else {
|
} else {
|
||||||
window, err = tomo.NewWindow(image.Rectangle { })
|
window, err = tomo.NewWindow(tomo.WindowKindNormal, image.Rectangle { })
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("objects: could not create swatch modal:", err)
|
log.Println("objects: could not create swatch modal:", err)
|
||||||
|
20
textinput.go
20
textinput.go
@ -205,7 +205,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
dot := this.Dot()
|
dot := this.Dot()
|
||||||
txt := this.text
|
txt := this.text
|
||||||
modifiers := this.box.Window().Modifiers()
|
modifiers := this.box.Window().Modifiers()
|
||||||
word := modifiers.Control
|
word := modifiers.Control()
|
||||||
changed := false
|
changed := false
|
||||||
|
|
||||||
defer func () {
|
defer func () {
|
||||||
@ -225,7 +225,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.multiline && !modifiers.Control {
|
if this.multiline && !modifiers.Control() {
|
||||||
switch {
|
switch {
|
||||||
case key == '\n', key == '\t':
|
case key == '\n', key == '\t':
|
||||||
typeRune()
|
typeRune()
|
||||||
@ -245,17 +245,17 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
txt, dot = text.Delete(txt, dot, word)
|
txt, dot = text.Delete(txt, dot, word)
|
||||||
changed = true
|
changed = true
|
||||||
return true
|
return true
|
||||||
case key.Printable() && !modifiers.Control:
|
case key.Printable() && !modifiers.Control():
|
||||||
typeRune()
|
typeRune()
|
||||||
return true
|
return true
|
||||||
case key == 'z' || key == 'Z' && modifiers.Control:
|
case key == 'z' || key == 'Z' && modifiers.Control():
|
||||||
if modifiers.Shift {
|
if modifiers.Shift() {
|
||||||
this.Redo()
|
this.Redo()
|
||||||
} else {
|
} else {
|
||||||
this.Undo()
|
this.Undo()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case key == 'y' && modifiers.Control:
|
case key == 'y' && modifiers.Control():
|
||||||
this.Redo()
|
this.Redo()
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
@ -266,7 +266,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
|
|||||||
func (this *TextInput) handleKeyUp (key input.Key, numpad bool) bool {
|
func (this *TextInput) handleKeyUp (key input.Key, numpad bool) bool {
|
||||||
modifiers := this.box.Window().Modifiers()
|
modifiers := this.box.Window().Modifiers()
|
||||||
|
|
||||||
if this.multiline && !modifiers.Control {
|
if this.multiline && !modifiers.Control() {
|
||||||
switch {
|
switch {
|
||||||
case key == '\n', key == '\t':
|
case key == '\n', key == '\t':
|
||||||
return true
|
return true
|
||||||
@ -280,11 +280,11 @@ func (this *TextInput) handleKeyUp (key input.Key, numpad bool) bool {
|
|||||||
return true
|
return true
|
||||||
case key == input.KeyDelete:
|
case key == input.KeyDelete:
|
||||||
return true
|
return true
|
||||||
case key.Printable() && !modifiers.Control:
|
case key.Printable() && !modifiers.Control():
|
||||||
return true
|
return true
|
||||||
case key == 'z' && modifiers.Control:
|
case key == 'z' && modifiers.Control():
|
||||||
return true
|
return true
|
||||||
case key == 'y' && modifiers.Control:
|
case key == 'y' && modifiers.Control():
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user