I want to draw undo props only when the shift is not pressed
import bpy
from bpy.types import Operator, Panel
from bpy.props import IntProperty
class XX_OT_Test(Operator):
bl_label = 'Test'
bl_idname = 'xx.test'
bl_options = {'REGISTER', 'UNDO'}
segments: IntProperty(
name = 'Segments',
description = 'Number of segments',
min = 8, max = 16,
default = 8,
)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
layout.prop(self, 'segments')
def invoke(self, context, event):
if event.shift:
print('Invoke')
else:
self.execute(context)
return {'FINISHED'}
def execute(self, context):
print('Execute')
return {'FINISHED'}
class LayoutDemoPanel(Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "Layout Demo"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Test"
def draw(self, context):
layout = self.layout
layout.operator("xx.test")
def register():
bpy.utils.register_class(XX_OT_Test)
bpy.utils.register_class(LayoutDemoPanel)
def unregister():
bpy.utils.unregister_class(XX_OT_Test)
bpy.utils.unregister_class(LayoutDemoPanel)
if __name__ == "__main__":
register()