Example #1
0
func (a *MyApp) HandleEvent(ev topsl.Event) bool {
	if a.panel != nil {
		if a.panel.HandleEvent(ev) {
			return true
		}

		switch ev := ev.(type) {
		case *topsl.KeyEvent:
			switch ev.Ch {
			case 0:
				if ev.Key == topsl.KeyCtrlL {
					topsl.AppRedraw()
				}
				return true
			case 'Q', 'q':
				topsl.AppFini()
				return true
			case 'S', 's':
				a.model.hide = false
				a.updateKeys()
				return true
			case 'H', 'h':
				a.model.hide = true
				a.updateKeys()
				return true
			case 'E', 'e':
				a.model.enab = true
				a.updateKeys()
				return true
			case 'D', 'd':
				a.model.enab = false
				a.updateKeys()
				return true
			}
		}
	}
	return true
}
Example #2
0
func (a *App) HandleEvent(ev topsl.Event) bool {
	switch ev := ev.(type) {
	case *topsl.KeyEvent:
		switch ev.Ch {
		case 0:
			// We intercept a few control keys up front, for global
			// handling.
			switch ev.Key {
			case topsl.KeyCtrlC:
				a.Quit()
				return true
			case topsl.KeyCtrlL:
				topsl.AppRedraw()
				return true
			}
		}
	}

	if a.panel != nil {
		return a.panel.HandleEvent(ev)
	}
	return false
}