Fix for 10.9
This commit is contained in:
+3
-3
@@ -1,8 +1,8 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = 'OGSwitch'
|
||||
s.version = '1.8'
|
||||
s.summary = 'Switch with icon'
|
||||
s.version = '1.0'
|
||||
s.summary = 'Switch control for macOS'
|
||||
s.homepage = 'https://github.com/OskarGroth/OGSwitch'
|
||||
s.license = {
|
||||
:type => 'MIT',
|
||||
@@ -19,6 +19,6 @@ s.platform = :osx, '10.9'
|
||||
s.source_files = 'OGSwitch/OGSwitch.{swift}'
|
||||
s.requires_arc = true
|
||||
s.screenshot = ""
|
||||
s.social_media_url = "https://twitter.com/cindoriapps"
|
||||
s.social_media_url = "https://twitter.com/oskargroth"
|
||||
|
||||
end
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
750F2E3E1E5D2CD000C20E79 /* OGSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 750F2E3C1E5D2CD000C20E79 /* OGSwitch.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
750F2E451E5D2CE100C20E79 /* OGSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750F2E441E5D2CE100C20E79 /* OGSwitch.swift */; };
|
||||
750F2E4D1E5D2D7100C20E79 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750F2E4C1E5D2D7100C20E79 /* AppDelegate.swift */; };
|
||||
750F2E4F1E5D2D7100C20E79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 750F2E4E1E5D2D7100C20E79 /* Assets.xcassets */; };
|
||||
750F2E521E5D2D7200C20E79 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 750F2E501E5D2D7200C20E79 /* MainMenu.xib */; };
|
||||
@@ -16,9 +14,6 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
750F2E391E5D2CD000C20E79 /* OGSwitch.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OGSwitch.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
750F2E3C1E5D2CD000C20E79 /* OGSwitch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OGSwitch.h; sourceTree = "<group>"; };
|
||||
750F2E3D1E5D2CD000C20E79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
750F2E441E5D2CE100C20E79 /* OGSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OGSwitch.swift; sourceTree = "<group>"; };
|
||||
750F2E4A1E5D2D7100C20E79 /* OGSwitchDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OGSwitchDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
750F2E4C1E5D2D7100C20E79 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@@ -28,13 +23,6 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
750F2E351E5D2CD000C20E79 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
750F2E471E5D2D7100C20E79 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -57,7 +45,6 @@
|
||||
750F2E3A1E5D2CD000C20E79 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
750F2E391E5D2CD000C20E79 /* OGSwitch.framework */,
|
||||
750F2E4A1E5D2D7100C20E79 /* OGSwitchDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
@@ -66,9 +53,7 @@
|
||||
750F2E3B1E5D2CD000C20E79 /* OGSwitch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
750F2E3C1E5D2CD000C20E79 /* OGSwitch.h */,
|
||||
750F2E441E5D2CE100C20E79 /* OGSwitch.swift */,
|
||||
750F2E3D1E5D2CD000C20E79 /* Info.plist */,
|
||||
);
|
||||
path = OGSwitch;
|
||||
sourceTree = "<group>";
|
||||
@@ -86,36 +71,7 @@
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
750F2E361E5D2CD000C20E79 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
750F2E3E1E5D2CD000C20E79 /* OGSwitch.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
750F2E381E5D2CD000C20E79 /* OGSwitch */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 750F2E411E5D2CD000C20E79 /* Build configuration list for PBXNativeTarget "OGSwitch" */;
|
||||
buildPhases = (
|
||||
750F2E341E5D2CD000C20E79 /* Sources */,
|
||||
750F2E351E5D2CD000C20E79 /* Frameworks */,
|
||||
750F2E361E5D2CD000C20E79 /* Headers */,
|
||||
750F2E371E5D2CD000C20E79 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = OGSwitch;
|
||||
productName = OGSwitch;
|
||||
productReference = 750F2E391E5D2CD000C20E79 /* OGSwitch.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
750F2E491E5D2D7100C20E79 /* OGSwitchDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 750F2E541E5D2D7200C20E79 /* Build configuration list for PBXNativeTarget "OGSwitchDemo" */;
|
||||
@@ -143,12 +99,6 @@
|
||||
LastUpgradeCheck = 0820;
|
||||
ORGANIZATIONNAME = "Oskar Groth";
|
||||
TargetAttributes = {
|
||||
750F2E381E5D2CD000C20E79 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = ZQK6SX26CE;
|
||||
LastSwiftMigration = 0820;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
750F2E491E5D2D7100C20E79 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = ZQK6SX26CE;
|
||||
@@ -169,20 +119,12 @@
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
750F2E381E5D2CD000C20E79 /* OGSwitch */,
|
||||
750F2E491E5D2D7100C20E79 /* OGSwitchDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
750F2E371E5D2CD000C20E79 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
750F2E481E5D2D7100C20E79 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -195,14 +137,6 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
750F2E341E5D2CD000C20E79 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
750F2E451E5D2CE100C20E79 /* OGSwitch.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
750F2E461E5D2D7100C20E79 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -267,7 +201,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
@@ -313,7 +247,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
@@ -322,51 +256,6 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
750F2E421E5D2CD000C20E79 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = ZQK6SX26CE;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = OGSwitch/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitch;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
750F2E431E5D2CD000C20E79 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = ZQK6SX26CE;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = OGSwitch/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitch;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
750F2E551E5D2D7200C20E79 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@@ -375,6 +264,7 @@
|
||||
DEVELOPMENT_TEAM = ZQK6SX26CE;
|
||||
INFOPLIST_FILE = OGSwitchDemo/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitchDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
@@ -389,6 +279,7 @@
|
||||
DEVELOPMENT_TEAM = ZQK6SX26CE;
|
||||
INFOPLIST_FILE = OGSwitchDemo/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitchDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
@@ -407,14 +298,6 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
750F2E411E5D2CD000C20E79 /* Build configuration list for PBXNativeTarget "OGSwitch" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
750F2E421E5D2CD000C20E79 /* Debug */,
|
||||
750F2E431E5D2CD000C20E79 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
750F2E541E5D2D7200C20E79 /* Build configuration list for PBXNativeTarget "OGSwitchDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
@@ -422,6 +305,7 @@
|
||||
750F2E561E5D2D7200C20E79 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2017 Oskar Groth. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// OGSwitch.h
|
||||
// OGSwitch
|
||||
//
|
||||
// Created by Oskar Groth on 2017-02-22.
|
||||
// Copyright © 2017 Oskar Groth. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
//! Project version number for OGSwitch.
|
||||
FOUNDATION_EXPORT double OGSwitchVersionNumber;
|
||||
|
||||
//! Project version string for OGSwitch.
|
||||
FOUNDATION_EXPORT const unsigned char OGSwitchVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <OGSwitch/PublicHeader.h>
|
||||
|
||||
|
||||
+17
-16
@@ -9,7 +9,9 @@
|
||||
import Cocoa
|
||||
import QuartzCore
|
||||
|
||||
public class OGSwitch : NSControl {
|
||||
//Can not be NSControl due to 10.9 issues: https://github.com/iluuu1994/ITSwitch/issues/21
|
||||
|
||||
public class OGSwitch : NSView {
|
||||
|
||||
@IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0) {
|
||||
didSet {
|
||||
@@ -54,6 +56,9 @@ public class OGSwitch : NSControl {
|
||||
let kDecreasedGoldenRatio:CGFloat = 1.38
|
||||
let kEnabledOpacity:Float = 1.0
|
||||
let kDisabledOpacity:Float = 0.5
|
||||
var dragEvents = 0
|
||||
public var action: Selector?
|
||||
public var target: AnyObject?
|
||||
public var isOn:Bool = false
|
||||
public var isActive:Bool = false
|
||||
public var hasDragged:Bool = false
|
||||
@@ -64,7 +69,7 @@ public class OGSwitch : NSControl {
|
||||
public var knobInsideLayer: CALayer?
|
||||
public var iconLayer = CALayer()
|
||||
public var lockInteraction: Bool = false
|
||||
override public var isEnabled: Bool {
|
||||
public var isEnabled: Bool = true {
|
||||
didSet {
|
||||
reloadLayerAnimated(animated: true)
|
||||
}
|
||||
@@ -78,13 +83,11 @@ public class OGSwitch : NSControl {
|
||||
|
||||
required public init?(coder:NSCoder) {
|
||||
super.init(coder: coder)
|
||||
|
||||
setup()
|
||||
}
|
||||
|
||||
override init(frame:NSRect) {
|
||||
super.init(frame: frame);
|
||||
|
||||
setup()
|
||||
}
|
||||
|
||||
@@ -129,7 +132,6 @@ public class OGSwitch : NSControl {
|
||||
internal func setupLayers() {
|
||||
rootLayer = CALayer()
|
||||
layer = rootLayer
|
||||
|
||||
wantsLayer = true
|
||||
|
||||
backgroundLayer = CALayer()
|
||||
@@ -164,8 +166,7 @@ public class OGSwitch : NSControl {
|
||||
knobInsideLayer!.shadowRadius = 1.0
|
||||
knobInsideLayer!.shadowOpacity = 0.35
|
||||
knobLayer!.addSublayer(knobInsideLayer!)
|
||||
|
||||
|
||||
|
||||
reloadLayerSize()
|
||||
reloadLayer()
|
||||
}
|
||||
@@ -173,14 +174,11 @@ public class OGSwitch : NSControl {
|
||||
internal func reloadLayerSize() {
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
|
||||
knobLayer!.frame = rectForKnob()
|
||||
knobInsideLayer!.frame = knobLayer!.bounds
|
||||
|
||||
backgroundLayer!.cornerRadius = backgroundLayer!.bounds.size.height / 2.0
|
||||
knobLayer!.cornerRadius = knobLayer!.bounds.size.height / 2.0
|
||||
knobInsideLayer!.cornerRadius = knobLayer!.bounds.size.height / 2.0
|
||||
|
||||
CATransaction.commit()
|
||||
}
|
||||
|
||||
@@ -203,7 +201,6 @@ public class OGSwitch : NSControl {
|
||||
knobLayer?.shadowColor = isEnabled ? NSColor.black.cgColor : NSColor.clear.cgColor
|
||||
rootLayer!.opacity = isEnabled ? kEnabledOpacity : kDisabledOpacity
|
||||
|
||||
|
||||
if hasDragged {
|
||||
let function = CAMediaTimingFunction(controlPoints: 0.25, 1.5, 0.5, 1)
|
||||
CATransaction.setAnimationTimingFunction(function)
|
||||
@@ -239,7 +236,6 @@ public class OGSwitch : NSControl {
|
||||
width = Double((bounds.width - 2.0 * kBorderLineWidth) / kDecreasedGoldenRatio)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var x:CGFloat = 0
|
||||
if (!hasDragged && !isOn) || (hasDragged && !isDraggingTowardsOn) {
|
||||
@@ -264,6 +260,7 @@ public class OGSwitch : NSControl {
|
||||
|
||||
|
||||
override public func mouseDown(with theEvent: NSEvent) {
|
||||
Swift.print("down")
|
||||
if !isEnabled || lockInteraction {
|
||||
return
|
||||
}
|
||||
@@ -272,10 +269,14 @@ public class OGSwitch : NSControl {
|
||||
}
|
||||
|
||||
override public func mouseDragged(with theEvent: NSEvent) {
|
||||
dragEvents += 1
|
||||
guard dragEvents > 3 else {
|
||||
return
|
||||
}
|
||||
dragEvents = 0
|
||||
if !isEnabled || lockInteraction {
|
||||
return
|
||||
}
|
||||
|
||||
hasDragged = true
|
||||
|
||||
let draggingPoint = convert(theEvent.locationInWindow, from: nil)
|
||||
@@ -284,10 +285,11 @@ public class OGSwitch : NSControl {
|
||||
}
|
||||
|
||||
override public func mouseUp(with theEvent: NSEvent) {
|
||||
dragEvents = 0
|
||||
if !isEnabled || lockInteraction {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var on = isOn
|
||||
isActive = false
|
||||
if hasDragged {
|
||||
@@ -296,7 +298,7 @@ public class OGSwitch : NSControl {
|
||||
else {
|
||||
on = !isOn
|
||||
}
|
||||
|
||||
|
||||
if isOn != on {
|
||||
isOn = on
|
||||
if action != nil {
|
||||
@@ -306,7 +308,6 @@ public class OGSwitch : NSControl {
|
||||
isOn = on
|
||||
}
|
||||
|
||||
|
||||
hasDragged = false
|
||||
isDraggingTowardsOn = false
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import Cocoa
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
|
||||
@IBOutlet weak var switchButton: OGSwitch!
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
@@ -24,13 +23,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
@IBAction func switchPress(_ sender: Any) {
|
||||
print("Trim is now: \(switchButton.isOn)")
|
||||
perform(#selector(timer), with: nil, afterDelay: 3)
|
||||
NSLog("Switch is now: \(switchButton.isOn)")
|
||||
// perform(#selector(timer), with: nil, afterDelay: 3)
|
||||
}
|
||||
|
||||
@objc func timer() {
|
||||
print("Trim is after now: \(switchButton.isOn)")
|
||||
switchButton.setOn(isOn: !switchButton.isOn, animated: false)
|
||||
NSLog("Switch is after timer trigger now: \(switchButton.isOn)")
|
||||
// switchButton.setOn(isOn: !switchButton.isOn, animated: false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user