62 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from lnx.logicnode.lnx_nodes import *
 | |
| 
 | |
| 
 | |
| class MouseNode(LnxLogicTreeNode):
 | |
|     """Activates the output on the given mouse event."""
 | |
|     bl_idname = 'LNMergedMouseNode'
 | |
|     bl_label = 'Mouse'
 | |
|     lnx_section = 'mouse'
 | |
|     lnx_version = 3
 | |
| 
 | |
|     property0: HaxeEnumProperty(
 | |
|         'property0',
 | |
|         items = [('started', 'Started', 'The mouse button begins to be pressed'),
 | |
|                  ('down', 'Down', 'The mouse button is pressed'),
 | |
|                  ('released', 'Released', 'The mouse button stops being pressed'),
 | |
|                  ('moved', 'Moved', 'Moved')],
 | |
|         name='', default='down')
 | |
|     property1: HaxeEnumProperty(
 | |
|         'property1',
 | |
|         items = [('left', 'Left', 'Left mouse button'),
 | |
|                  ('middle', 'Middle', 'Middle mouse button'),
 | |
|                  ('right', 'Right', 'Right mouse button'),
 | |
|                  ('side1', 'Side 1', 'Side 1 mouse button'),
 | |
|                  ('side2', 'Side 2', 'Side 2 mouse button')],
 | |
|         name='', default='left')
 | |
|     property2: HaxeBoolProperty(
 | |
|         'property2',
 | |
|         name='Include Debug Console',
 | |
|         description=(
 | |
|             'If disabled, this node does not react to mouse press events'
 | |
|             ' over the debug console area. Enable this option to catch those events'
 | |
|         )
 | |
|     )
 | |
| 
 | |
|     def lnx_init(self, context):
 | |
|         self.add_output('LnxNodeSocketAction', 'Out')
 | |
|         self.add_output('LnxBoolSocket', 'State')
 | |
| 
 | |
|     def draw_buttons(self, context, layout):
 | |
|         layout.prop(self, 'property0')
 | |
| 
 | |
|         if self.property0 != 'moved':
 | |
|             layout.prop(self, 'property1')
 | |
|             layout.prop(self, 'property2')
 | |
| 
 | |
|     def draw_label(self) -> str:
 | |
|         return f'{self.bl_label}: {self.property1}'
 | |
| 
 | |
|     def get_replacement_node(self, node_tree: bpy.types.NodeTree):
 | |
|         if 0 <= self.lnx_version < 2:
 | |
|             return NodeReplacement.Identity(self)
 | |
| 
 | |
|         elif self.lnx_version == 2:
 | |
|             return NodeReplacement(
 | |
|                 'LNMergedMouseNode', self.lnx_version, 'LNMergedMouseNode', 3,
 | |
|                 in_socket_mapping={}, out_socket_mapping={0: 0, 1: 1},
 | |
|                 property_mapping={'property0': 'property0', 'property1': 'property1'},
 | |
|                 property_defaults={'property2': True}
 | |
|             )
 | |
| 
 | |
|         raise LookupError()
 |