Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GestureHUD companion xcode project (AppDelegate.swift)
import Cocoa
@testable import Utils
@testable import Element
@NSApplicationMain
class AppDelegate:NSObject, NSApplicationDelegate {
weak var window:NSWindow!
var win:NSWindow?/*<--The window must be a class variable, local variables doesn't work*/
var menu:Menu?
func applicationDidFinishLaunching(_ aNotification:Notification) {
quickTest()
}
func quickTest(){
setup()
_ = window.contentView?.addSubView(TestView())
}
func setup(){
window.contentView = InteractiveView()
}
func applicationWillTerminate(_ aNotification:Notification) {
print("Good-bye")
}
}
class TestView:InteractiveView{
lazy var gestureHUD:GestureHUD = GestureHUD(self)
init(){
super.init(frame: NSRect.init(0, 0, 200, 200))
self.acceptsTouchEvents = true/*Enables gestures*/
self.wantsRestingTouches = true/*Makes sure all touches are registered. Doesn't register when used in playground*/
let rect = RectGraphic(0,0,200,200,FillStyle(.blue),nil)
self.addSubview(rect.graphic)
rect.draw()
_ = gestureHUD
}
required init(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension TestView{
override func touchesBegan(with event:NSEvent) {
gestureHUD.touchesBegan(event)
}
override func touchesMoved(with event:NSEvent) {
gestureHUD.touchesMoved(event)
}
override func touchesEnded(with event:NSEvent) {
gestureHUD.touchesEnded(event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.