We could easily replace the context menus in the render window by changing the existing one to shift+right click in case we needed to access the clipboard with copy/paste and set right click to a context menu of our own after we unbound the existing context menu from the rmb, but there’s no way to do that for the context menu that shows up in the explorer.
I can’t remember the last time I used the context menu in the render window – I don’t think I ever use it. I do however use the context menu in the explorer on a frequent basis. Unfortunately, as of this moment, there’s no way for me to modify what’s in it. Here are some things I’d like to do with it:
and a lot of other things I don’t want to have to photoshop into the existing context menu: send to layer > 1,2,3,4,5,6,…, convert to > , preview sound, send to > <serverstorage, replicatedstorage, workspace, etc>, set adornee, set object value (e.g. weld Part0/Part), edit in render window (custom plugin that edits grip position of certain weapons in 3D instead of manually trying numbers), configure (custom GUI that pops up allowing me to edit module settings), and even more but I don’t want to spend all day on this.
Please: plugin:CreateContextButton(buttonText, buttonIcon, objectType, contextIndex, scope, subMenu) returns contextButton
where buttonText is the button’s text
where buttonIcon is what appears in the left column of the context menu – empty string is no icon
objectType is the type of object that this will appear in the context menu for (i.e. I wouldn’t want “Scale model” to appear in a light’s context menu, plus that’s pretty much the point of context menus to only show what’s relevant)
contextIndex dictates where the contextButton would appear in the context menu (cut/copy/paste section would be numbered at 0, group/ungroup/etc at 10, insert part/object/from file at 20, save/publish at 30) – if I have 3 buttons with the same index it just displays them in the order they were created.
scope attempts to group the buttons. For instance, if I have one plugin that creates some at index 2 and another one that creates more at index 2 and they end up getting mixed and matched but I want them to stay grouped together I provide a scope (e.g. the plugin’s name) and the context menu attempts to group buttons of the same context index and scope.
subMenu allows creation of sub context menu like there is with Insert Object in existing context menu
examples:
scaleModel = plugin:CreateContextButton(“Scale Model”, “”, “Model”, 11, “echobuildstuff”)
sendablePlaces = {[“Server Storage”] = game.ServerStorage; [“Replicated Storage”] = game.ReplicatedStorage}
sendTo = plugin:CreateContextButton(“Send To”, “Instance”, “”, 6, “echobuildstuff”, sendablePlaces)
scaleModel.Click:connect(function(selectedObject)
–selectedObject is NOT selection:Get()[1]. It is the item that was right clicked to bring up the context menu
promptScale(selectedObject)
end)
sendTo.Click:connect(function(selectedObject, selectedSubMenuitemName)
for i,v in next, game.Selection:Get() do
v.Parent = sendablePlaces[selectedSubMenuItemName]
end
end)
or something like that. You guys will no doubt come up with a better API than I.