UX: WebView native-feel + Context-Menu Redesign + Startup-Fix
- Disable text selection (CSS user-select:none) + block browser context menu (contextmenu preventDefault) in all panels - ContextMenu: pill items, accent hover, entrance animation, optional title header — controlled via single ContextMenu.css - EbenenManager + GeschossManager: show layer name as menu title - startup.py: skip splash on Cmd+N when plugin already loaded - startup.py: hook NewDocument so display-modes apply to new docs
This commit is contained in:
+21
-2
@@ -267,10 +267,12 @@ def _build_inline_template():
|
||||
html = f.read().decode("utf-8")
|
||||
|
||||
placeholder_script = '<script>' + _MODE_SCRIPT_PLACEHOLDER + '</script>'
|
||||
_no_select = '<style>*{-webkit-user-select:none!important;user-select:none!important;}</style>'
|
||||
_no_ctx = '<script>document.addEventListener("contextmenu",function(e){e.preventDefault();},true);</script>'
|
||||
if "</head>" in html:
|
||||
html = html.replace("</head>", placeholder_script + "</head>")
|
||||
html = html.replace("</head>", placeholder_script + _no_select + _no_ctx + "</head>")
|
||||
else:
|
||||
html = placeholder_script + html
|
||||
html = placeholder_script + _no_select + _no_ctx + html
|
||||
|
||||
def inline_css(m):
|
||||
p = os.path.join(dist_dir, m.group(1).lstrip("./").replace("/", os.sep))
|
||||
@@ -353,6 +355,15 @@ def attach_webview(panel, bridge, mode):
|
||||
wv.ExecuteScript("window.RHINO_MODE=true;")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
wv.ExecuteScript(
|
||||
"var _ds=document.createElement('style');"
|
||||
"_ds.textContent='*{-webkit-user-select:none!important;user-select:none!important;}';"
|
||||
"document.head.appendChild(_ds);"
|
||||
"document.addEventListener('contextmenu',function(e){e.preventDefault();},true);"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def on_idle(s, e):
|
||||
Rhino.RhinoApp.Idle -= on_idle
|
||||
@@ -440,6 +451,14 @@ def open_satellite_window(mode, params=None, title=None, size=(420, 560),
|
||||
def on_loaded(s, e):
|
||||
try: wv.ExecuteScript("window.RHINO_MODE=true;")
|
||||
except Exception: pass
|
||||
try:
|
||||
wv.ExecuteScript(
|
||||
"var _ds=document.createElement('style');"
|
||||
"_ds.textContent='*{-webkit-user-select:none!important;user-select:none!important;}';"
|
||||
"document.head.appendChild(_ds);"
|
||||
"document.addEventListener('contextmenu',function(e){e.preventDefault();},true);"
|
||||
)
|
||||
except Exception: pass
|
||||
|
||||
wv.DocumentTitleChanged += on_title_
|
||||
wv.DocumentLoaded += on_loaded
|
||||
|
||||
Reference in New Issue
Block a user