Auto enlarge search field when editing (#4067)

This commit is contained in:
A Cœur 2022-11-02 09:40:24 +08:00 committed by GitHub
parent 611d36ac84
commit fa7100bdef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -15,6 +15,7 @@
<outlet property="fNoFilterButton" destination="9" id="27"/>
<outlet property="fPauseFilterButton" destination="6" id="28"/>
<outlet property="fSearchField" destination="10" id="31"/>
<outlet property="fSearchFieldMinWidthConstraint" destination="Ven-bt-DjP" id="X9R-JZ-TVl"/>
<outlet property="fSeedFilterButton" destination="7" id="32"/>
<outlet property="view" destination="2" id="33"/>
</connections>

View File

@ -24,7 +24,7 @@ typedef NS_ENUM(NSInteger, FilterTypeTag) {
FilterTypeTagTracker = 402,
};
@interface FilterBarController ()
@interface FilterBarController ()<NSSearchFieldDelegate>
@property(nonatomic) IBOutlet FilterButton* fNoFilterButton;
@property(nonatomic) IBOutlet FilterButton* fActiveFilterButton;
@ -34,6 +34,7 @@ typedef NS_ENUM(NSInteger, FilterTypeTag) {
@property(nonatomic) IBOutlet FilterButton* fErrorFilterButton;
@property(nonatomic) IBOutlet NSSearchField* fSearchField;
@property(nonatomic) IBOutlet NSLayoutConstraint* fSearchFieldMinWidthConstraint;
@property(nonatomic) IBOutlet NSPopUpButton* fGroupsButton;
@ -135,8 +136,11 @@ typedef NS_ENUM(NSInteger, FilterTypeTag) {
[self updateGroupsButton];
//update when groups change
// update when groups change
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateGroups:) name:@"UpdateGroups" object:nil];
// update when filter change
self.fSearchField.delegate = self;
}
- (void)dealloc
@ -263,6 +267,16 @@ typedef NS_ENUM(NSInteger, FilterTypeTag) {
[self.view.window makeFirstResponder:self.fSearchField];
}
- (void)searchFieldDidStartSearching:(NSSearchField*)sender
{
[self.fSearchFieldMinWidthConstraint animator].constant = 95;
}
- (void)searchFieldDidEndSearching:(NSSearchField*)sender
{
[self.fSearchFieldMinWidthConstraint animator].constant = 48;
}
- (void)setSearchType:(id)sender
{
NSString* oldFilterType = [NSUserDefaults.standardUserDefaults stringForKey:@"FilterSearchType"];