Enable Escape key to cancel to previous page

Fixes #53

Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
This commit is contained in:
Mark D Horn
2018-09-19 16:12:40 -07:00
committed by Mark Horn
parent 5c1b69c8d4
commit fc773a2fbf
+13
View File
@@ -327,6 +327,19 @@ func (page *BasePage) setup(tui *Tui, id int, btns int, returnID int) {
"Use [Tab] or the arrow keys [up and down] to navigate", Fixed)
page.window.SetVisible(false)
// Escape-key cancel's this screen and returns
// same as the default 'Cancel' button
page.window.OnKeyDown(func(ev clui.Event, data interface{}) bool {
if ev.Key == term.KeyEsc {
page.action = ActionCancelButton
page.GotoPage(returnID)
page.action = ActionNone
return true
}
return false
}, nil)
}
func (page *BasePage) newWindow() {