-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically update color text fields when changed
This closes #5 Move files into groups, and general refactoring
- Loading branch information
1 parent
f3ec307
commit 9d9bbc9
Showing
11 changed files
with
101 additions
and
40 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
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,38 @@ | ||
// | ||
// ColorRepresentingTextField.swift | ||
// Color Picker Plus | ||
// | ||
// Created by Viktor Hundahl Strate on 27/06/2018. | ||
// Copyright © 2018 Viktor Hundahl Strate. All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
|
||
class ColorRepresentingTextField: NSTextField, NSTextFieldDelegate { | ||
|
||
var isHexField: Bool = false | ||
|
||
override func awakeFromNib() { | ||
super.awakeFromNib() | ||
self.delegate = self | ||
} | ||
|
||
override func controlTextDidChange(_ obj: Notification) { | ||
Logger.debug(message: "Text field changed") | ||
|
||
if isHexField { | ||
if self.stringValue.count != 6 { | ||
Logger.debug(message: "Hex field is not 6 characters long, skipping color update") | ||
return | ||
} | ||
|
||
if RGB.fromHEX(NSString(string: self.stringValue)) == nil { | ||
Logger.debug(message: "Hex field does not contain a valid hex value, skipping color update") | ||
return | ||
} | ||
} | ||
|
||
ColorPickerPlus.shared.colorFieldChanged(self) | ||
} | ||
|
||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.