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

Method makePasteMenu

core/tree.go:1347–1375  ·  view source on GitHub ↗

makePasteMenu makes the menu of options for paste events Optional function is typically the DropFinalize but could also be other actions to take after each optional action.

(m *Scene, md mimedata.Mimes, fun func())

Source from the content-addressed store, hash-verified

1345// Optional function is typically the DropFinalize but could also be other actions
1346// to take after each optional action.
1347func (tr *Tree) makePasteMenu(m *Scene, md mimedata.Mimes, fun func()) {
1348 NewButton(m).SetText("Assign To").OnClick(func(e events.Event) {
1349 tr.pasteAssign(md)
1350 if fun != nil {
1351 fun()
1352 }
1353 })
1354 NewButton(m).SetText("Add to Children").OnClick(func(e events.Event) {
1355 tr.pasteChildren(md, events.DropCopy)
1356 if fun != nil {
1357 fun()
1358 }
1359 })
1360 if !tr.IsRoot("") && tr.root.This != tr.This {
1361 NewButton(m).SetText("Insert Before").OnClick(func(e events.Event) {
1362 tr.pasteBefore(md, events.DropCopy)
1363 if fun != nil {
1364 fun()
1365 }
1366 })
1367 NewButton(m).SetText("Insert After").OnClick(func(e events.Event) {
1368 tr.pasteAfter(md, events.DropCopy)
1369 if fun != nil {
1370 fun()
1371 }
1372 })
1373 }
1374 NewButton(m).SetText("Cancel")
1375}
1376
1377// pasteAssign assigns mime data (only the first one!) to this node
1378func (tr *Tree) pasteAssign(md mimedata.Mimes) {

Callers 2

pasteMenuMethod · 0.95
DragDropMethod · 0.95

Calls 8

pasteAssignMethod · 0.95
pasteChildrenMethod · 0.95
IsRootMethod · 0.95
pasteBeforeMethod · 0.95
pasteAfterMethod · 0.95
NewButtonFunction · 0.85
OnClickMethod · 0.45
SetTextMethod · 0.45

Tested by

no test coverage detected