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

Method paste

core/textfield.go:1059–1067  ·  view source on GitHub ↗

paste inserts text from the clipboard at current cursor position; if cursor is within a current selection, that selection is replaced.

()

Source from the content-addressed store, hash-verified

1057// paste inserts text from the clipboard at current cursor position; if
1058// cursor is within a current selection, that selection is replaced.
1059func (tf *TextField) paste() { //types:add
1060 data := tf.Clipboard().Read([]string{mimedata.TextPlain})
1061 if data != nil {
1062 if tf.cursorPos >= tf.selectStart && tf.cursorPos < tf.selectEnd {
1063 tf.deleteSelection()
1064 }
1065 tf.insertAtCursor(data.Text(mimedata.TextPlain))
1066 }
1067}
1068
1069// insertAtCursor inserts the given text at current cursor position.
1070func (tf *TextField) insertAtCursor(str string) {

Callers 2

InitMethod · 0.95
handleKeyEventsMethod · 0.95

Calls 5

deleteSelectionMethod · 0.95
insertAtCursorMethod · 0.95
ReadMethod · 0.65
ClipboardMethod · 0.65
TextMethod · 0.45

Tested by

no test coverage detected