MCPcopy Create free account
hub / github.com/cogentcore/core / handleKeyEvents

Method handleKeyEvents

core/textfield.go:1629–1803  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1627}
1628
1629func (tf *TextField) handleKeyEvents() {
1630 tf.OnKeyChord(func(e events.Event) {
1631 kf := keymap.Of(e.KeyChord())
1632 if DebugSettings.KeyEventTrace {
1633 slog.Info("TextField KeyInput", "widget", tf, "keyFunction", kf)
1634 }
1635 if !tf.StateIs(states.Focused) && kf == keymap.Abort {
1636 return
1637 }
1638
1639 // first all the keys that work for both inactive and active
1640 switch kf {
1641 case keymap.MoveRight:
1642 e.SetHandled()
1643 tf.shiftSelect(e)
1644 tf.cursorForward(1)
1645 tf.offerComplete()
1646 case keymap.WordRight:
1647 e.SetHandled()
1648 tf.shiftSelect(e)
1649 tf.cursorForwardWord(1)
1650 tf.offerComplete()
1651 case keymap.MoveLeft:
1652 e.SetHandled()
1653 tf.shiftSelect(e)
1654 tf.cursorBackward(1)
1655 tf.offerComplete()
1656 case keymap.WordLeft:
1657 e.SetHandled()
1658 tf.shiftSelect(e)
1659 tf.cursorBackwardWord(1)
1660 tf.offerComplete()
1661 case keymap.MoveDown:
1662 if tf.numLines > 1 {
1663 e.SetHandled()
1664 tf.shiftSelect(e)
1665 tf.cursorDown(1)
1666 }
1667 case keymap.MoveUp:
1668 if tf.numLines > 1 {
1669 e.SetHandled()
1670 tf.shiftSelect(e)
1671 tf.cursorUp(1)
1672 }
1673 case keymap.Home:
1674 e.SetHandled()
1675 tf.shiftSelect(e)
1676 tf.cancelComplete()
1677 tf.cursorStart()
1678 case keymap.End:
1679 e.SetHandled()
1680 tf.shiftSelect(e)
1681 tf.cancelComplete()
1682 tf.cursorEnd()
1683 case keymap.SelectMode:
1684 e.SetHandled()
1685 tf.cancelComplete()
1686 tf.selectModeToggle()

Callers 1

InitMethod · 0.95

Calls 15

shiftSelectMethod · 0.95
cursorForwardMethod · 0.95
offerCompleteMethod · 0.95
cursorForwardWordMethod · 0.95
cursorBackwardMethod · 0.95
cursorBackwardWordMethod · 0.95
cursorDownMethod · 0.95
cursorUpMethod · 0.95
cancelCompleteMethod · 0.95
cursorStartMethod · 0.95
cursorEndMethod · 0.95
selectModeToggleMethod · 0.95

Tested by

no test coverage detected