aboutsummaryrefslogtreecommitdiff
path: root/insert_into_popup_menu-plugin.tcl
blob: 04a75d9f57a1a65bcf5e0bf0f587232786a59eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

# for more info: http://tcl.tk/man/tcl8.5/TkCmd/menu.htm

# create the item, then stick it to the canvas using a 'mouseup' message
proc popup_create_put {putitem} {
    pdsend "$::focused_window $putitem"
    pdsend "$::focused_window mouseup $::popup_xcanvas $::popup_ycanvas 1"
}

# create our submenu
menu .popup.create
# fix menu font size on Windows with tk scaling = 1
if {$::windowingsystem eq "win32"} {.popup.create configure -font menufont}

# add items to our submenu
# (wrapping the label like [_ ""] means that text will be localized)
.popup.create add command -label [_ "Object"] -command {popup_create_put "obj"}
.popup.create add command -label [_ "Message"] -command {popup_create_put "msg"}
.popup.create add command -label [_ "Number"] -command {popup_create_put "floatatom"}
.popup.create add command -label [_ "Symbol"] -command {popup_create_put "symbolatom"}
.popup.create add command -label [_ "Comment"] -command {popup_create_put "text"}
.popup.create add  separator
.popup.create add command -label [_ "Array"] -command {pdsend "$::focused_window menuarray"}

# insert our submenu as the 0th element on the popup
.popup insert 0 cascade -label [_ "Put"] -menu .popup.create