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

Method deleteSelection

core/textfield.go:1023–1041  ·  view source on GitHub ↗

deleteSelection deletes any selected text, without adding to clipboard -- returns text deleted

()

Source from the content-addressed store, hash-verified

1021// deleteSelection deletes any selected text, without adding to clipboard --
1022// returns text deleted
1023func (tf *TextField) deleteSelection() string {
1024 tf.selectUpdate()
1025 if !tf.hasSelection() {
1026 return ""
1027 }
1028 cut := tf.selection()
1029 tf.edited = true
1030 tf.editText = append(tf.editText[:tf.selectStart], tf.editText[tf.selectEnd:]...)
1031 if tf.cursorPos > tf.selectStart {
1032 if tf.cursorPos < tf.selectEnd {
1033 tf.cursorPos = tf.selectStart
1034 } else {
1035 tf.cursorPos -= tf.selectEnd - tf.selectStart
1036 }
1037 }
1038 tf.selectReset()
1039 tf.NeedsRender()
1040 return cut
1041}
1042
1043// copy copies any selected text to the clipboard.
1044func (tf *TextField) copy() { //types:add

Callers 6

cursorBackspaceMethod · 0.95
cursorDeleteMethod · 0.95
cursorBackspaceWordMethod · 0.95
cursorDeleteWordMethod · 0.95
cutMethod · 0.95
pasteMethod · 0.95

Calls 5

selectUpdateMethod · 0.95
hasSelectionMethod · 0.95
selectionMethod · 0.95
selectResetMethod · 0.95
NeedsRenderMethod · 0.80

Tested by

no test coverage detected