fix: allow 0 for input field (Appearance settings)
This commit is contained in:
@@ -215,7 +215,7 @@ static inline NSButton* Checkbox(SettingsAppearanceView *self, CGFloat x, NSStri
|
|||||||
rv.identifier = pref;
|
rv.identifier = pref;
|
||||||
rv.delegate = self;
|
rv.delegate = self;
|
||||||
NSInteger val = UserPrefsInt(pref);
|
NSInteger val = UserPrefsInt(pref);
|
||||||
if (val > 0) {
|
if (val >= 0) {
|
||||||
rv.stringValue = [NSString stringWithFormat:@"%ld", val];
|
rv.stringValue = [NSString stringWithFormat:@"%ld", val];
|
||||||
} else {
|
} else {
|
||||||
rv.accessibilityValueDescription = rv.placeholderString;
|
rv.accessibilityValueDescription = rv.placeholderString;
|
||||||
@@ -231,11 +231,9 @@ static inline NSButton* Checkbox(SettingsAppearanceView *self, CGFloat x, NSStri
|
|||||||
NSString *pref = sender.identifier;
|
NSString *pref = sender.identifier;
|
||||||
|
|
||||||
NSInteger newVal = sender.integerValue;
|
NSInteger newVal = sender.integerValue;
|
||||||
if (newVal == 0 && sender.stringValue.length > 0) {
|
BOOL isEmpty = newVal == 0 && sender.stringValue.length == 0;
|
||||||
sender.stringValue = @""; // clear input to show placeholder text
|
sender.accessibilityValueDescription = isEmpty ? sender.placeholderString : nil;
|
||||||
}
|
UserPrefsSetInt(pref, isEmpty ? -1 : newVal);
|
||||||
sender.accessibilityValueDescription = newVal > 0 ? nil : sender.placeholderString;
|
|
||||||
UserPrefsSetInt(pref, newVal > 0 ? newVal : -1);
|
|
||||||
|
|
||||||
BOOL hitReturn = [[obj.userInfo valueForKey:NSTextMovementUserInfoKey] integerValue] == NSTextMovementReturn;
|
BOOL hitReturn = [[obj.userInfo valueForKey:NSTextMovementUserInfoKey] integerValue] == NSTextMovementReturn;
|
||||||
if (hitReturn) {
|
if (hitReturn) {
|
||||||
|
|||||||
Reference in New Issue
Block a user