mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Merge 4f8c545544 into 4d0abeb37c
This commit is contained in:
commit
1369c2011a
1 changed files with 42 additions and 1 deletions
|
|
@ -256,6 +256,30 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
|
|||
config.userContentController = userContentController;
|
||||
self.userContentController = userContentController;
|
||||
|
||||
WKUserScript *doubleClickScript = [[WKUserScript alloc]
|
||||
initWithSource:@"document.addEventListener('dblclick', function(e) { \
|
||||
let el = e.target; \
|
||||
while (el) { \
|
||||
if (el.hasAttribute && el.hasAttribute('data-wails-drag')) { \
|
||||
window.webkit.messageHandlers.external.postMessage('titlebar-doubleclick'); \
|
||||
e.preventDefault(); \
|
||||
return; \
|
||||
} \
|
||||
const style = window.getComputedStyle(el); \
|
||||
if (style.getPropertyValue('-webkit-app-region') === 'drag' || \
|
||||
style.getPropertyValue('--wails-draggable') === 'drag') { \
|
||||
window.webkit.messageHandlers.external.postMessage('titlebar-doubleclick'); \
|
||||
e.preventDefault(); \
|
||||
return; \
|
||||
} \
|
||||
el = el.parentElement; \
|
||||
} \
|
||||
}, true);"
|
||||
injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
|
||||
forMainFrameOnly:false];
|
||||
[userContentController addUserScript:doubleClickScript];
|
||||
[doubleClickScript release];
|
||||
|
||||
if (self.devtoolsEnabled) {
|
||||
[config.preferences setValue:@YES forKey:@"developerExtrasEnabled"];
|
||||
}
|
||||
|
|
@ -494,13 +518,30 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
|
|||
|
||||
NSString *m = message.body;
|
||||
|
||||
if ( [m isEqualToString:@"titlebar-doubleclick"] ) {
|
||||
if ( [self IsFullScreen] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *action = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey:@"AppleActionOnDoubleClick"];
|
||||
|
||||
if (action == nil || [action isEqualToString:@"Maximize"]) {
|
||||
[self ToggleMaximise];
|
||||
} else if ([action isEqualToString:@"Minimize"]) {
|
||||
[self Minimise];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for drag
|
||||
if ( [m isEqualToString:@"drag"] ) {
|
||||
if( [self IsFullScreen] ) {
|
||||
return;
|
||||
}
|
||||
if( self.mouseEvent != nil ) {
|
||||
[self.mainWindow performWindowDragWithEvent:self.mouseEvent];
|
||||
[self.mainWindow performWindowDragWithEvent:self.mouseEvent];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue