HandleEvent checks for a resize event or a mouse event on the tab bar otherwise it will forward the event to the currently active tab
(event tcell.Event)
| 100 | // HandleEvent checks for a resize event or a mouse event on the tab bar |
| 101 | // otherwise it will forward the event to the currently active tab |
| 102 | func (t *TabList) HandleEvent(event tcell.Event) { |
| 103 | switch e := event.(type) { |
| 104 | case *tcell.EventResize: |
| 105 | t.Resize() |
| 106 | case *tcell.EventMouse: |
| 107 | mx, my := e.Position() |
| 108 | switch e.Buttons() { |
| 109 | case tcell.Button1: |
| 110 | if my == t.Y && len(t.List) > 1 { |
| 111 | if mx == 0 { |
| 112 | t.Scroll(-4) |
| 113 | } else if mx == t.Width-1 { |
| 114 | t.Scroll(4) |
| 115 | } else { |
| 116 | ind := t.LocFromVisual(buffer.Loc{mx, my}) |
| 117 | if ind != -1 { |
| 118 | t.SetActive(ind) |
| 119 | } |
| 120 | } |
| 121 | return |
| 122 | } |
| 123 | case tcell.ButtonNone: |
| 124 | if t.List[t.Active()].release { |
| 125 | // Mouse release received, while already released |
| 126 | t.ResetMouse() |
| 127 | return |
| 128 | } |
| 129 | case tcell.WheelUp: |
| 130 | if my == t.Y && len(t.List) > 1 { |
| 131 | t.Scroll(4) |
| 132 | return |
| 133 | } |
| 134 | case tcell.WheelDown: |
| 135 | if my == t.Y && len(t.List) > 1 { |
| 136 | t.Scroll(-4) |
| 137 | return |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | t.List[t.Active()].HandleEvent(event) |
| 142 | } |
| 143 | |
| 144 | // Display updates the names and then displays the tab bar |
| 145 | func (t *TabList) Display() { |
nothing calls this directly
no test coverage detected