mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3 mac] Refactor drag to use common code
This commit is contained in:
parent
9b48cc1799
commit
50387948df
3 changed files with 20 additions and 15 deletions
|
|
@ -818,6 +818,18 @@ static void windowSetFrameless(void *window, bool frameless) {
|
|||
});
|
||||
}
|
||||
|
||||
static void startDrag(void *window) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// get main window
|
||||
WebviewWindow* nsWindow = (WebviewWindow*)window;
|
||||
|
||||
// Get delegate
|
||||
WebviewWindowDelegate* windowDelegate = (WebviewWindowDelegate*)[nsWindow delegate];
|
||||
|
||||
// start drag
|
||||
[windowDelegate startDrag:nsWindow];
|
||||
});
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
|
|
@ -1239,6 +1251,6 @@ func (w *macosWebviewWindow) setHTML(html string) {
|
|||
}
|
||||
|
||||
func (w *macosWebviewWindow) startDrag() error {
|
||||
// Unused - handled by the native code
|
||||
C.startDrag(w.nsWindow)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
- (void)handleLeftMouseUp:(NSWindow *)window;
|
||||
- (void)handleLeftMouseDown:(NSEvent*)event;
|
||||
- (void)startDrag:(WebviewWindow*)window;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,26 +57,18 @@ extern bool hasListeners(unsigned int);
|
|||
self.leftMouseEvent = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) startDrag:(WebviewWindow*)window {
|
||||
[window performWindowDragWithEvent:self.leftMouseEvent];
|
||||
}
|
||||
|
||||
// Handle script messages from the external bridge
|
||||
- (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
|
||||
NSString *m = message.body;
|
||||
// TODO: Standardise drag by sending the drag event back to Go
|
||||
if ( [m isEqualToString:@"drag"] ) {
|
||||
/*
|
||||
if( [self IsFullScreen] ) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if( self.leftMouseEvent != nil ) {
|
||||
WKWebView *webView = message.webView;
|
||||
WebviewWindow *window = (WebviewWindow*)webView.window;
|
||||
[window performWindowDragWithEvent:self.leftMouseEvent];
|
||||
}
|
||||
return;
|
||||
}
|
||||
const char *_m = [m UTF8String];
|
||||
processMessage(self.windowId, _m);
|
||||
}
|
||||
|
||||
- (void)handleLeftMouseDown:(NSEvent *)event {
|
||||
self.leftMouseEvent = event;
|
||||
NSWindow *window = [event window];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue