-
-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improves PreferencesPanel UX, partially implements #49
implements requested changes from Code-Review and contains also refactoring and more features and improvements - Application Wide: changes all exceptions to NSError (required for error handling via sheet in panel) - PreferencesPanel: adds display of current value of Sliders - PreferencesPanel: adds validation with visualisation for TextFields (whitelist for KeyCode and ranges for maxScreenUsage & windowDisplayDelay) during editing, window open and close - PreferencesPanel: adds error sheet (in-window modal) at all known possible errors to display error information and ask the user how to proceed - PreferencesPanel: removes Restart button (and relaunch code in Application) - PreferencesPanel: adds Preferences being now live - PreferencesPanel: removes invisibleText workaround - PreferencesPanel: adds TextField value save on each keyDown event (if valid and changed) - PreferencesPanel: adds window activation/deactivation - PreferencesPanel: changes label texts of some Preferences - ...
- Loading branch information
Showing
6 changed files
with
245 additions
and
138 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
34 changes: 34 additions & 0 deletions
34
alt-tab-macos/logic/PreferencesPanelNSTextFieldEditable.swift
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,34 @@ | ||
import Cocoa | ||
|
||
class PreferencesPanelNSTextFieldEditable: NSTextField, NSTextFieldDelegate { | ||
|
||
var validationHandler: ((String)->Bool)? | ||
|
||
// protocol method | ||
func controlTextDidChange(_ obj: Notification) { | ||
visualizeValidationState(isValid()) | ||
let textField = obj.object as! PreferencesPanelNSTextFieldEditable | ||
sendAction(textField.action, to: textField.target) | ||
} | ||
|
||
// custom method | ||
func visualizeValidationState(_ isValid: Bool) -> Void { | ||
if !isValid { | ||
wantsLayer = true | ||
layer?.borderColor = NSColor.systemRed.cgColor | ||
layer?.borderWidth = 1 | ||
} else { | ||
wantsLayer = false | ||
} | ||
} | ||
|
||
// custom method | ||
func isValid() -> Bool { | ||
if let handler = validationHandler { | ||
return handler(stringValue) | ||
} | ||
|
||
return true | ||
} | ||
|
||
} |
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
Oops, something went wrong.