use own event handler for layout views if set
This commit is contained in:
parent
66605df473
commit
8a0bf8f515
@ -138,6 +138,10 @@ func (g *BorderLayout) Layout() (prefWidth, prefHeight int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *BorderLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
func (g *BorderLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
||||||
|
if g.KeyPressed != nil {
|
||||||
|
return g.KeyPressed(event)
|
||||||
|
}
|
||||||
|
|
||||||
for _, view := range g.Views() {
|
for _, view := range g.Views() {
|
||||||
if consumed := view.OnKeyPressed(event); consumed {
|
if consumed := view.OnKeyPressed(event); consumed {
|
||||||
return true
|
return true
|
||||||
@ -147,6 +151,10 @@ func (g *BorderLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *BorderLayout) OnMouseEvent(event *tui.MouseEvent) (consumed bool) {
|
func (g *BorderLayout) OnMouseEvent(event *tui.MouseEvent) (consumed bool) {
|
||||||
|
if g.MouseEvent != nil {
|
||||||
|
return g.MouseEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
for slot, dim := range g.viewDims {
|
for slot, dim := range g.viewDims {
|
||||||
if event.Position.In(dim) {
|
if event.Position.In(dim) {
|
||||||
g.views[slot].OnMouseEvent(event)
|
g.views[slot].OnMouseEvent(event)
|
||||||
|
@ -41,6 +41,10 @@ func (v *CoordLayout) Layout() (prefWidth, prefHeight int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *CoordLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
func (g *CoordLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
||||||
|
if g.KeyPressed != nil {
|
||||||
|
return g.KeyPressed(event)
|
||||||
|
}
|
||||||
|
|
||||||
for _, view := range g.Views() {
|
for _, view := range g.Views() {
|
||||||
if view.OnKeyPressed(event) {
|
if view.OnKeyPressed(event) {
|
||||||
return true
|
return true
|
||||||
|
@ -141,6 +141,10 @@ func (g *FlowLayout) Layout() (prefWidth, prefHeight int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *FlowLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
func (g *FlowLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
||||||
|
if g.KeyPressed != nil {
|
||||||
|
return g.KeyPressed(event)
|
||||||
|
}
|
||||||
|
|
||||||
for _, view := range g.Views() {
|
for _, view := range g.Views() {
|
||||||
if view.OnKeyPressed(event) {
|
if view.OnKeyPressed(event) {
|
||||||
return true
|
return true
|
||||||
|
@ -102,6 +102,10 @@ func (g *SeperatorLayout) Layout() (prefWidth, prefHeight int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *SeperatorLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
func (g *SeperatorLayout) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
|
||||||
|
if g.KeyPressed != nil {
|
||||||
|
return g.KeyPressed(event)
|
||||||
|
}
|
||||||
|
|
||||||
for _, view := range g.Views() {
|
for _, view := range g.Views() {
|
||||||
if view.OnKeyPressed(event) {
|
if view.OnKeyPressed(event) {
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user