Browse Source

No need to explicitly hide the cursor in no-cursor primitives.

tablepad
Oliver 5 years ago
parent
commit
9659be0e90
  1. 3
      application.go
  2. 4
      button.go
  3. 5
      checkbox.go
  4. 27
      doc.go
  5. 5
      dropdown.go

3
application.go

@ -244,6 +244,9 @@ func (a *Application) SetFocus(p Primitive) *Application {
a.focus.Blur()
}
a.focus = p
if a.screen != nil {
a.screen.HideCursor()
}
a.Unlock()
p.Focus(func(p Primitive) {
a.SetFocus(p)

4
button.go

@ -115,10 +115,6 @@ func (b *Button) Draw(screen tcell.Screen) {
}
Print(screen, b.label, x, y, width, AlignCenter, labelColor)
}
if b.focus.HasFocus() {
screen.HideCursor()
}
}
// InputHandler returns the handler for this primitive.

5
checkbox.go

@ -138,11 +138,6 @@ func (c *Checkbox) Draw(screen tcell.Screen) {
checkedRune = ' '
}
screen.SetContent(x, y, checkedRune, nil, fieldStyle)
// Hide cursor.
if c.focus.HasFocus() {
screen.HideCursor()
}
}
// InputHandler returns the handler for this primitive.

27
doc.go

@ -2,6 +2,33 @@
Package tview implements primitives for terminal based applications. It uses
github.com/gdamore/tcell.
Hello World
Here is a very basic example showing a box with the title "Hello, world!":
package main
import (
"github.com/rivo/tview"
)
func main() {
box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
panic(err)
}
}
First, we create a box primitive with a border and a title. Then we create an
application, set the box as its root primitive, and run the event loop. It
exits when the application's Stop() function is called or when Ctrl-C is
pressed.
If we have a primitive which consumes key presses, we call the application's
SetFocus() function to redirect all key presses to that primitive. Most
primitives then offer ways to install handlers that allow you to react to any
actions performed on them.
No mouse input (yet).
*/
package tview

5
dropdown.go

@ -231,11 +231,6 @@ func (d *DropDown) Draw(screen tcell.Screen) {
d.list.SetRect(lx, ly, lwidth, lheight)
d.list.Draw(screen)
}
// No cursor for this primitive.
if d.focus.HasFocus() {
screen.HideCursor()
}
}
// InputHandler returns the handler for this primitive.

Loading…
Cancel
Save