I'm working on something similar to the native picture in picture.
I want to move this window, but can't because there is no titlebar (it's hidden and window.stylemask
is fullSizeContentView
) in it and it's fully filled with the webView.
So, I can't just click on titlebar and drag to move this window.
P.S. Sorry for my english. I hope the goal is clear
You can subclass the webview to catch -mouseDown:
events, and then pass the NSEvent to -[NSWindow performWindowDragWithEvent:]
.
Apple has sample code which uses this technique to start a window drag after the mouse moves some minimum distance, while still handling normal clicks. If you want to support basic interaction with the webview, this might be a good approach.
(Overriding -mouseDown:
seems to work for WKWebView, it may not work with the legacy WebView. It's a bit of a hack, but you could use an overlay view to catch those events instead.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With