Created
January 19, 2017 13:11
-
-
Save p2or/5138cef979edf657606a37838379712e to your computer and use it in GitHub Desktop.
Detect Ctrl-Click BoolProp #Blender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great !! Thanks again for taking the time