Fix crash on TAB
This commit is contained in:
parent
4b95d078c9
commit
189788fcd6
|
@ -203,7 +203,6 @@ func (c *Composer) resizeTopView(ev termbox.Event) bool {
|
|||
}
|
||||
|
||||
w, h := view.Size()
|
||||
wm, hm := view.Constraints()
|
||||
w1, h1 := w, h
|
||||
minW, minH := view.Constraints()
|
||||
if ev.Key == termbox.KeyArrowUp && minH < h {
|
||||
|
|
|
@ -171,6 +171,9 @@ func (c *ControlBase) Parent() Control {
|
|||
return c.parent
|
||||
}
|
||||
|
||||
func (c *ControlBase) RecalculateConstraints() {
|
||||
}
|
||||
|
||||
//---------- debug ----------------
|
||||
func (c *ControlBase) Logger() *log.Logger {
|
||||
if c.parent == nil {
|
||||
|
|
6
frame.go
6
frame.go
|
@ -95,6 +95,12 @@ func (f *Frame) RecalculateConstraints() {
|
|||
if newW != width || newH != height {
|
||||
f.SetConstraints(newW, newH)
|
||||
}
|
||||
|
||||
if f.parent != nil {
|
||||
f.parent.RecalculateConstraints()
|
||||
} else if f.view != nil {
|
||||
f.view.RecalculateConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Frame) AddChild(c Control, scale int) {
|
||||
|
|
|
@ -59,6 +59,7 @@ type View interface {
|
|||
SetScale(int)
|
||||
TabStop() bool
|
||||
Colors() (term.Attribute, term.Attribute)
|
||||
RecalculateConstraints()
|
||||
|
||||
Logger() *log.Logger
|
||||
}
|
||||
|
@ -86,5 +87,7 @@ type Control interface {
|
|||
Parent() Control
|
||||
Colors() (term.Attribute, term.Attribute)
|
||||
|
||||
RecalculateConstraints()
|
||||
|
||||
Logger() *log.Logger
|
||||
}
|
||||
|
|
2
label.go
2
label.go
|
@ -23,7 +23,7 @@ func NewLabel(view View, parent Control, w, h int, title string, scale int) *Lab
|
|||
c.tabSkip = true
|
||||
|
||||
c.fg = ColorWhite
|
||||
c.bg = ColorBlack
|
||||
c.bg = ColorBlackBold
|
||||
|
||||
if parent != nil {
|
||||
parent.AddChild(c, scale)
|
||||
|
|
|
@ -276,7 +276,9 @@ func (w *Window) ProcessEvent(ev Event) bool {
|
|||
if ev.Type == EventKey && (ev.Key == term.KeyTab || (ev.Mod&term.ModAlt != 0 && (ev.Key == term.KeyPgup || ev.Key == term.KeyPgdn))) {
|
||||
forward := ev.Key != term.KeyPgup
|
||||
ctrl := w.ActiveControl()
|
||||
ctrl.ProcessEvent(Event{Type: EventActivate, X: 0})
|
||||
if ctrl != nil {
|
||||
ctrl.ProcessEvent(Event{Type: EventActivate, X: 0})
|
||||
}
|
||||
ctrl = w.NextControl(ctrl, forward)
|
||||
if ctrl != nil {
|
||||
// w.Logger().Printf("Activate control: %v", ctrl)
|
||||
|
|
Loading…
Reference in New Issue