-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHookExample.swift
More file actions
53 lines (51 loc) · 1.84 KB
/
HookExample.swift
File metadata and controls
53 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
enum HookExample: CaseIterable {
case NSWindow_setTitle
case NSWindow_miniaturize
case NSApplication_sendEvent
case NSMenuItem_title
case NSColor_labelColor
}
extension HookExample {
var selector: String {
switch self {
case .NSWindow_setTitle:
return "-[NSWindow setTitle:]"
case .NSWindow_miniaturize:
return "-[NSWindow miniaturize:]"
case .NSApplication_sendEvent:
return "-[NSApplication sendEvent:]"
case .NSMenuItem_title:
return "-[NSMenuItem title]"
case .NSColor_labelColor:
return "+[NSColor labelColor]"
}
}
var description: String {
switch self {
case .NSWindow_setTitle:
return """
An object hook on the main NSWindow that uppercases the title and wraps it with \
decorative markers whenever it’s set. This can be tested using the text field below.
"""
case .NSWindow_miniaturize:
return """
An object hook on the main NSWindow that intercepts miniaturization and shows \
an alert instead of minimizing the window.
"""
case .NSApplication_sendEvent:
return """
A class hook on NSApplication that logs all events passed through sendEvent(_:).
"""
case .NSMenuItem_title:
return """
A class hook on NSMenuItem that wraps all menu item titles with decorative markers, \
visible in the main menu and the text field’s context menu.
"""
case .NSColor_labelColor:
return """
A class hook that overrides the standard label color by hooking the corresponding \
class method on NSColor. Affects text in this window and menus.
"""
}
}
}