pod install
and openxxx.xcworkspace
file.- rename
SampleWidget
class to whatever you want. If you have renamed it, you will also need to change the NSPrincipalClass part of the info.plist. - Create the view you want to display. (touch bar's height is 30point)
- Assign the instance of the view you want to display to the view property of the Widget class.
Set the developer's name to PKWidgetAuthor
in Info.plist
.
Conform the widget class to the PKScreenEdgeMouseDelegate
protocol.
/// Mouse entered at location in the touch bar.
func screenEdgeController(_ controller: PKScreenEdgeController, mouseEnteredAtLocation location: NSPoint, in view: NSView)
/// Mouse did move at location in the touch bar.
func screenEdgeController(_ controller: PKScreenEdgeController, mouseMovedAtLocation location: NSPoint, in view: NSView)
///Mouse clicked at location in the touch bar.
func screenEdgeController(_ controller: PKScreenEdgeController, mouseClickAtLocation location: NSPoint, in view: NSView)
//Mouse exited the touch bar at location.
func screenEdgeController(_ controller: PKScreenEdgeController, mouseExitedAtLocation location: NSPoint, in view: NSView)
Set the preference viewController class's name to PKWidgetPreferenceClas
s in Info.plist
.
ViewController class must confirm to PKWidgetPreference
.