-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_integration.py
More file actions
43 lines (32 loc) · 1.19 KB
/
menu_integration.py
File metadata and controls
43 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# pyright: reportInvalidTypeForm=false
from bpy.types import UI_MT_button_context_menu
from .utils.logging import get_logger
from .utils.ui_utils import ic
log = get_logger(__name__)
def draw_numpad_entry(self, context):
ptr = getattr(context, "button_pointer", None)
prop = getattr(context, "button_prop", None)
if ptr and prop and prop.type in {"INT", "FLOAT"}:
self.layout.separator()
op = self.layout.operator(
"wm.numeric_input", text="On-Screen Numpad", icon=ic("TOPBAR")
)
else:
log.debug("No numeric property found")
def register_menu():
try:
UI_MT_button_context_menu.append(draw_numpad_entry)
log.debug("Calculator menu integration registered")
except Exception as e:
log.error(f"Failed to register calculator menu: {e}")
def unregister_menu():
try:
UI_MT_button_context_menu.remove(draw_numpad_entry)
log.debug("Calculator menu integration unregistered")
except Exception as e:
log.warning(f"Failed to unregister calculator menu: {e}")
def cleanup_menu_on_reload():
try:
unregister_menu()
except:
pass