mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[macos] Handle close event from editors
This commit is contained in:
@ -222,6 +222,11 @@
|
||||
name:CEFEventNameEditorAppReady
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(onCEFEditorEvent:)
|
||||
name:CEFEventNameEditorEvent
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(onCEFEditorAppActionRequest:)
|
||||
name:CEFEventNameEditorAppActionRequest
|
||||
@ -1524,6 +1529,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onCEFEditorEvent:(NSNotification *)notification {
|
||||
if (notification && notification.userInfo) {
|
||||
id json = notification.userInfo;
|
||||
|
||||
NSString * viewId = json[@"viewId"];
|
||||
NSDictionary * data = json[@"data"];
|
||||
|
||||
if (viewId && data) {
|
||||
NSString * action = data[@"action"];
|
||||
|
||||
if (action && [action isEqualToString:@"close"]) {
|
||||
if (ASCTabView * tab = [self.tabsControl tabWithUUID:viewId]) {
|
||||
[self.tabsControl removeTab:tab selected:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onCEFEditorAppActionRequest:(NSNotification *)notification {
|
||||
if (notification && notification.userInfo) {
|
||||
id json = notification.userInfo;
|
||||
|
||||
@ -556,6 +556,13 @@ public:
|
||||
userInfo:@{
|
||||
@"viewId": [NSString stringWithFormat:@"%d", senderId]
|
||||
}];
|
||||
} else if (cmd.find(L"editor:event") != std::wstring::npos) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameEditorEvent
|
||||
object:nil
|
||||
userInfo:@{
|
||||
@"viewId": [NSString stringWithFormat:@"%d", senderId],
|
||||
@"data": [[NSString stringWithstdwstring:param] dictionary]
|
||||
}];
|
||||
} else if (cmd.find(L"editor:request") != std::wstring::npos) {
|
||||
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithDictionary:@{@"viewId": [NSString stringWithFormat:@"%d", senderId]}];
|
||||
[params addEntriesFromDictionary:[[NSString stringWithstdwstring:param] dictionary]];
|
||||
|
||||
@ -113,6 +113,7 @@ static NSString * const CEFEventNameSaveBeforSign = @"CEF_saveBeforeSi
|
||||
static NSString * const CEFEventNameOpenSSLCertificate = @"CEF_openSSLCertificate";
|
||||
static NSString * const CEFEventNameEditorDocumentReady = @"CEF_editorDocumentReady";
|
||||
static NSString * const CEFEventNameEditorAppReady = @"CEF_editorAppReady";
|
||||
static NSString * const CEFEventNameEditorEvent = @"CEF_editorEvent";
|
||||
static NSString * const CEFEventNameEditorAppActionRequest = @"CEF_editorAppActionRequest";
|
||||
static NSString * const CEFEventNameEditorOpenFolder = @"CEF_editorOpenFolder";
|
||||
static NSString * const CEFEventNameDocumentFragmentBuild = @"CEF_documentFragmentBuild";
|
||||
|
||||
Reference in New Issue
Block a user