iOS: Fix typing in search filter in servers menu crashing the launcher, also change it so pressing 'done' in search filter input just closes the onscreen keyboard instead of trying to connect to server

This commit is contained in:
UnknownShadow200 2022-05-10 22:49:29 +10:00
parent 22fb91a0c1
commit 07bc5645df
3 changed files with 9 additions and 4 deletions

View File

@ -1239,6 +1239,7 @@ static void ServersScreen_Init(struct LScreen* s_) {
s->btnConnect.OnClick = ServersScreen_Connect;
s->btnRefresh.OnClick = ServersScreen_Refresh;
s->iptSearch.skipsEnter = true;
s->iptSearch.TextChanged = ServersScreen_SearchChanged;
s->iptHash.TextChanged = ServersScreen_HashChanged;
s->iptHash.ClipboardFilter = ServersScreen_HashFilter;

View File

@ -50,6 +50,7 @@ struct LWidgetVTABLE {
cc_bool dirty; /* Whether this widget needs to be redrawn */ \
cc_bool opaque; /* Whether this widget completely obscures background behind it */ \
cc_uint8 type; /* Type of this widget */ \
cc_bool skipsEnter; /* Whether clicking this widget DOESN'T trigger OnEnterWidget */ \
void (*OnClick)(void* widget); /* Called when widget is clicked */ \
void (*OnHover)(void* widget); /* Called when widget is hovered over */ \
void (*OnUnhover)(void* widget);/*Called when widget is no longer hovered over */ \

View File

@ -686,7 +686,8 @@ static NSString* cellID = @"CC_Cell";
}
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return FetchServersTask.numServers;
struct LTable* w = (struct LTable*)FindWidgetForView(tableView);
return w ? w->rowsCount : 0;
}
// === UITableViewDelegate ===
@ -708,10 +709,12 @@ static NSString* cellID = @"CC_Cell";
// === UITextFieldDelegate ===
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
struct LWidget* w = Launcher_Active->onEnterWidget;
struct LWidget* w = FindWidgetForView(textField);
if (w == NULL) return YES;
struct LWidget* sel = Launcher_Active->onEnterWidget;
if (w) {
w->OnClick(w);
if (sel && !w->skipsEnter) {
sel->OnClick(sel);
} else {
[textField resignFirstResponder];
}