Page 1 of 1
Modify RMB context sensitive menus
Posted: Tue Jul 16, 2013 12:34 am
I have 2 little questions about RMB menus
When I create a panel with properties, i can add -to a float property for exemple- a keyframe or driver, or add to keying set etc... with RMB menu.
But I don't want the user to have access to this.
So the first question is : How can I disable those options ?
I mean, like in Vertex Groups list, the RMB menu is shorter, and some options are unavailable.
And, the contrary : how can I add a custom option to RMB menu ?
I couldn't find anything consistent to guide me
, so if anyone could help me, I'll be very grateful.
Posted: Wed Jul 17, 2013 6:30 pm
Here's a simple script to explain the problem :
Code: Select all
from bpy.props import *
# Store properties in the active object
bpy.types.Object.TestFloat = FloatProperty(
name = "Float",
description = "Enter a float",
default = 5.25,
min = -100,
max = 100)
# Menu in UI region
bl_label = "Property panel"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOL_PROPS"
def draw(self, context):
layout = self.layout
obj = bpy.context.object
So in the tool properties I have the float value. When I RMB click on it, the menu shows some options, such as "Add driver", "Insert Keyframe"...
I've found some threads on the web such as
http://www.blenderartist.org/forum/show ... in-a-scene
But it's not really clear for me...
Is it possible to modify RMB context sensitive menus in a simple script ?
I've looked a bit in included addons that have shorter menus on their properties, and nothing in the code explicitely says how to modify the RMB menus...
The only difference I've found is that the class drawing the menu and where the properties are defined derivates from bpy.types.Operator and there's absolutely no class from bpy.types.Panel...
I'd be thankful if someone could give me a hint, where to look in the API for example...
Thank you !
Posted: Mon Jul 22, 2013 4:38 pm
those context menus are built-in and apperently not accessible by python. You could, however, replace them entirely by binding a custom menu to the right mouse button. I don't recommend it though
Posted: Mon Jul 22, 2013 6:42 pm
That's what I feared, but at least I won't spend much time to try to modify it.
Thank you for your answer