     @objc func viewTapped() {
         self.view.endEditing(true)
     }
-    
-    // MARK: UITextFieldDelegate
-    
-    open func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
-        var newString = textField.text! as NSString;
-        newString = newString.replacingCharacters(in: range, with: string) as NSString;
-        
-        // allow zero characters if they want to clear and re-input everything
-        if(newString.length == 0){
-            return true;
-            
-        // limit to 8 char
-        }else if(newString.length > 8){
-            return false;
-        }
-        
-        // only allow input if text remains a valid hex int
-        if let _ = UInt64(newString as String, radix:16) {
-            return true;
-        }else{
-            return false;
-        }
-    }
-    
-    // MARK: BradColorComponentDelegate
-    
+}
+
+// MARK: BradColorComponentDelegate
+extension BradColorPicker : BradColorComponentDelegate {
     // color component changed
     // - update other components, wheel and display color
     func colorComponentChanged(_ sender: BradColorComponent) {

    func bradColorPicked(_ color:UIColor);
}

open class BradColorPicker : UIViewController, BradColorComponentDelegate, UITextFieldDelegate {
    
    @IBOutlet weak var displayColor: BradColorDisplay!
    @IBOutlet weak var colorPicker: BradColorWheel!

        updateColor();
    }
}

// MARK: UITextFieldDelegate
extension BradColorPicker : UITextFieldDelegate {
    open func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        var newString = textField.text! as NSString;
        newString = newString.replacingCharacters(in: range, with: string) as NSString;
        
        // allow zero characters if they want to clear and re-input everything
        if(newString.length == 0){
            return true;
            
        // limit to 8 char
        }else if(newString.length > 8){
            return false;
        }
        
        // only allow input if text remains a valid hex int
        if let _ = UInt64(newString as String, radix:16) {
            return true;
        }else{
            return false;
        }
    }
    
    open func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        return true
    }
}
