-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[osx] update menuitems after setting main menu
On Mac, the system will add several menu items to Edit menu, like `Emoji & Symbols` or `Start Dictation...`. These items are added after setting main menu. This patch will update menu items after setting main menu. Then developers can iterate items under edit menu and remove corresponding items. fixed #2812
- Loading branch information
Cong Liu
committed
Jul 20, 2016
1 parent
69a472a
commit 043e1f5
Showing
20 changed files
with
258 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef CONTENT_NW_SRC_API_BASE_BASE_MAC_H_ | ||
#define CONTENT_NW_SRC_API_BASE_BASE_MAC_H_ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSObject (AssociatedObject) | ||
@property (nonatomic, assign) void* associatedObject; | ||
@end | ||
|
||
#endif // CONTENT_NW_SRC_API_BASE_BASE_MAC_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#import "content/nw/src/api/base/base_mac.h" | ||
#import <objc/runtime.h> | ||
|
||
@interface CppWrapper : NSObject { | ||
void* _obj; | ||
} | ||
+ (id) createFromCppObject:(void*) obj; | ||
- (id) initWithCppObject:(void*) obj; | ||
- (void*) obj; | ||
@end | ||
|
||
@implementation CppWrapper | ||
|
||
+ (id) createFromCppObject:(void*) obj { | ||
return [[CppWrapper alloc] initWithCppObject:obj]; | ||
} | ||
|
||
- (id) initWithCppObject:(void*) obj { | ||
_obj = obj; | ||
return self; | ||
} | ||
|
||
- (void*) obj { | ||
return _obj; | ||
} | ||
|
||
@end | ||
|
||
@implementation NSObject (AssociatedObject) | ||
@dynamic associatedObject; | ||
|
||
- (void)setAssociatedObject:(void*)object { | ||
objc_setAssociatedObject(self, @selector(associatedObject), [CppWrapper createFromCppObject:object], OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
- (void*)associatedObject { | ||
CppWrapper* wrapper = objc_getAssociatedObject(self, @selector(associatedObject)); | ||
return wrapper == nil ? nil : [wrapper obj]; | ||
} | ||
|
||
// - (void)setAssociatedCppObject:(void*)obj { | ||
// [self setAssociatedObject: [CppWrapper createFromCppObject:obj]]; | ||
// } | ||
|
||
// - (void*)associatedCppObject { | ||
// id obj = [self associatedObject]; | ||
// if ([obj isKindOfClass: [CppWrapper class]]) { | ||
// return [(CppWrapper*)obj obj]; | ||
// } | ||
// return nullptr; | ||
// } | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.