Added getters for some callback functions. Resolves #65

This commit is contained in:
Oliver 2018-03-10 23:30:42 +01:00
parent c96894c0cf
commit 45acc0d895
2 changed files with 30 additions and 0 deletions

View File

@ -59,6 +59,12 @@ func (a *Application) SetInputCapture(capture func(event *tcell.EventKey) *tcell
return a return a
} }
// GetInputCapture returns the function installed with SetInputCapture() or nil
// if no such function has been installed.
func (a *Application) GetInputCapture() func(event *tcell.EventKey) *tcell.EventKey {
return a.inputCapture
}
// Run starts the application and thus the event loop. This function returns // Run starts the application and thus the event loop. This function returns
// when Stop() was called. // when Stop() was called.
func (a *Application) Run() error { func (a *Application) Run() error {
@ -214,6 +220,12 @@ func (a *Application) SetBeforeDrawFunc(handler func(screen tcell.Screen) bool)
return a return a
} }
// GetBeforeDrawFunc returns the callback function installed with
// SetBeforeDrawFunc() or nil if none has been installed.
func (a *Application) GetBeforeDrawFunc() func(screen tcell.Screen) bool {
return a.beforeDraw
}
// SetAfterDrawFunc installs a callback function which is invoked after the root // SetAfterDrawFunc installs a callback function which is invoked after the root
// primitive was drawn during screen updates. // primitive was drawn during screen updates.
// //
@ -223,6 +235,12 @@ func (a *Application) SetAfterDrawFunc(handler func(screen tcell.Screen)) *Appli
return a return a
} }
// GetAfterDrawFunc returns the callback function installed with
// SetAfterDrawFunc() or nil if none has been installed.
func (a *Application) GetAfterDrawFunc() func(screen tcell.Screen) {
return a.afterDraw
}
// SetRoot sets the root primitive for this application. If "fullscreen" is set // SetRoot sets the root primitive for this application. If "fullscreen" is set
// to true, the root primitive's position will be changed to fill the screen. // to true, the root primitive's position will be changed to fill the screen.
// //

12
box.go
View File

@ -124,6 +124,12 @@ func (b *Box) SetDrawFunc(handler func(screen tcell.Screen, x, y, width, height
return b return b
} }
// GetDrawFunc returns the callback function which was installed with
// SetDrawFunc() or nil if no such function has been installed.
func (b *Box) GetDrawFunc() func(screen tcell.Screen, x, y, width, height int) (int, int, int, int) {
return b.draw
}
// wrapInputHandler wraps an input handler (see InputHandler()) with the // wrapInputHandler wraps an input handler (see InputHandler()) with the
// functionality to capture input (see SetInputCapture()) before passing it // functionality to capture input (see SetInputCapture()) before passing it
// on to the provided (default) input handler. // on to the provided (default) input handler.
@ -155,6 +161,12 @@ func (b *Box) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKe
return b return b
} }
// GetInputCapture returns the function installed with SetInputCapture() or nil
// if no such function has been installed.
func (b *Box) GetInputCapture() func(event *tcell.EventKey) *tcell.EventKey {
return b.inputCapture
}
// SetBackgroundColor sets the box's background color. // SetBackgroundColor sets the box's background color.
func (b *Box) SetBackgroundColor(color tcell.Color) *Box { func (b *Box) SetBackgroundColor(color tcell.Color) *Box {
b.backgroundColor = color b.backgroundColor = color