Skip to content

Instantly share code, notes, and snippets.

@p2or
Created January 19, 2017 13:11
Show Gist options
  • Save p2or/5138cef979edf657606a37838379712e to your computer and use it in GitHub Desktop.
Save p2or/5138cef979edf657606a37838379712e to your computer and use it in GitHub Desktop.
Detect Ctrl-Click BoolProp #Blender
import bpy
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
def invoke(self, context, event):
ev = []
if event.ctrl:
ev.append("Ctrl")
if event.shift:
ev.append("Shift")
if event.alt:
ev.append("Alt")
if event.oskey:
ev.append("OS")
ev.append("Click")
self.report({'INFO'}, "+".join(ev))
return {'FINISHED'}
class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
wm = context.window_manager
layout.prop(wm, "my_bool")
def upd(self, context):
bpy.ops.object.simple_operator('INVOKE_DEFAULT')
def register():
bpy.utils.register_class(HelloWorldPanel)
bpy.utils.register_class(SimpleOperator)
bpy.types.WindowManager.my_bool = bpy.props.BoolProperty(update=upd)
def unregister():
bpy.utils.unregister_class(HelloWorldPanel)
del bpy.types.WindowManager.my_bool
if __name__ == "__main__":
register()
@Nikos-Prinios
Copy link

Great !! Thanks again for taking the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment