edit_other.go
func (e *EditField) ProcessEvent(event Event) bool {
	if !e.Active() || !e.Enabled() {
		return false
	}

	if event.Type == EventActivate && event.X == 0 {
		term.HideCursor()
	}

	if event.Type == EventKey && event.Key != term.KeyTab {
		if e.onKeyPress != nil {
			res := e.onKeyPress(event.Key, event.Ch)
			if res {
				return true
			}
		}

		switch event.Key {
		case term.KeyEnter:
			return false
		case term.KeySpace:
			e.insertRune(' ')
			return true
		case term.KeyBackspace, term.KeyBackspace2:
			e.backspace()
			return true
		case term.KeyDelete:
			e.del()
			return true
		case term.KeyArrowLeft:
			e.charLeft()
			return true
		case term.KeyHome:
			e.home()
			return true
		case term.KeyEnd:
			e.end()
			return true
		case term.KeyCtrlR:
			if !e.readonly {
				e.Clear()
			}
			return true
		case term.KeyArrowRight:
			e.charRight()
			return true
		case term.KeyCtrlC:
			if !e.showStars {
				clipboard.WriteAll(e.Title())
			}
			return true
		case term.KeyCtrlV:
			if !e.readonly {
				s, _ := clipboard.ReadAll()
				e.SetTitle(s)
				e.end()
			}
			return true
		default:
			if event.Ch != 0 {
				e.insertRune(event.Ch)
				return true
			}
		}
		return false
	}

	return false
}
func (e *EditField) ProcessEvent(event Event) bool {
	if !e.Active() || !e.Enabled() {
		return false
	}

	if event.Type == EventActivate && event.X == 0 {
		term.HideCursor()
	}

	if event.Type == EventKey && event.Key != term.KeyTab {
		if e.onKeyPress != nil {
			res := e.onKeyPress(event.Key, event.Ch)
			if res {
				return true
			}
		}

		switch event.Key {
		case term.KeyEnter:
			return false
		case term.KeySpace:
			e.insertRune(' ')
			return true
		case term.KeyBackspace, term.KeyBackspace2:
			e.backspace()
			return true
		case term.KeyDelete:
			e.del()
			return true
		case term.KeyArrowLeft:
			e.charLeft()
			return true
		case term.KeyHome:
			e.home()
			return true
		case term.KeyEnd:
			e.end()
			return true
		case term.KeyCtrlR:
			if !e.readonly {
				e.Clear()
			}
			return true
		case term.KeyArrowRight:
			e.charRight()
			return true
		case term.KeyCtrlC:
			if !e.showStars {
				clipboard.WriteAll(e.Title())
			}
			return true
		case term.KeyCtrlV:
			if !e.readonly {
				s, _ := clipboard.ReadAll()
				e.SetTitle(s)
				e.end()
			}
			return true
		default:
			if event.Ch != 0 {
				e.insertRune(event.Ch)
				return true
			}
		}
		return false
	}

	return false
}
func ( e * EditField ) ProcessEvent ( event Event ) bool { if ! e . Active ( ) || ! e . Enabled ( ) { return false } if event . Type == EventActivate && event . X == 0 { term . HideCursor ( ) } if event . Type == EventKey && event . Key != term . KeyTab { if e . onKeyPress != nil { res := e . onKeyPress ( event . Key , event . Ch ) if res { return true } } switch event . Key { case term . KeyEnter : return false case term . KeySpace : e . insertRune ( ' ' ) return true case term . KeyBackspace , term . KeyBackspace2 : e . backspace ( ) return true case term . KeyDelete : e . del ( ) return true case term . KeyArrowLeft : e . charLeft ( ) return true case term . KeyHome : e . home ( ) return true case term . KeyEnd : e . end ( ) return true case term . KeyCtrlR : if ! e . readonly { e . Clear ( ) } return true case term . KeyArrowRight : e . charRight ( ) return true case term . KeyCtrlC : if ! e . showStars { clipboard . WriteAll ( e . Title ( ) ) } return true case term . KeyCtrlV : if ! e . readonly { s , _ := clipboard . ReadAll ( ) e . SetTitle ( s ) e . end ( ) } return true default : if event . Ch != 0 { e . insertRune ( event . Ch ) return true } } return false } return false }
/*
ProcessEvent processes all events come from the control parent. If a control
processes an event it should return true. If the method returns false it means
that the control do not want or cannot process the event and the caller sends
the event to the control parent
*/
/ * ProcessEvent processes all events come from the control parent . If a control processes an event it should return true . If the method returns false it means that the control do not want or cannot process the event and the caller sends the event to the control parent