Mercurial > dwindows
comparison ios/dw.m @ 2458:689261c29745
iOS: DWContainer should generate selection event on deselect too.
Move UIInterfaceStyle code into DWObj so it can run on the main thread.
It seemed to work on a secondary thread, but XCode warns about it.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 13 Apr 2021 22:05:46 +0000 |
parents | 181e48c5dc0c |
children | ddc6d49d1110 |
comparison
equal
deleted
inserted
replaced
2457:181e48c5dc0c | 2458:689261c29745 |
---|---|
1231 { | 1231 { |
1232 windowfunc(params[1]); | 1232 windowfunc(params[1]); |
1233 } | 1233 } |
1234 } | 1234 } |
1235 } | 1235 } |
1236 -(void)getUserInterfaceStyle:(id)param | |
1237 { | |
1238 NSMutableArray *array = param; | |
1239 UIUserInterfaceStyle style = [hiddenWindow overrideUserInterfaceStyle]; | |
1240 int retval; | |
1241 | |
1242 switch(style) | |
1243 { | |
1244 case UIUserInterfaceStyleLight: | |
1245 retval = DW_DARK_MODE_DISABLED; | |
1246 break; | |
1247 case UIUserInterfaceStyleDark: | |
1248 retval = DW_DARK_MODE_FORCED; | |
1249 break; | |
1250 default: /* UIUserInterfaceStyleUnspecified */ | |
1251 style = [[[hiddenWindow rootViewController] traitCollection] userInterfaceStyle]; | |
1252 } | |
1253 switch(style) | |
1254 { | |
1255 case UIUserInterfaceStyleLight: | |
1256 retval = DW_DARK_MODE_BASIC; | |
1257 break; | |
1258 case UIUserInterfaceStyleDark: | |
1259 retval = DW_DARK_MODE_FULL; | |
1260 break; | |
1261 default: /* UIUserInterfaceStyleUnspecified */ | |
1262 retval = DW_FEATURE_UNSUPPORTED; | |
1263 break; | |
1264 } | |
1265 [array addObject:[NSNumber numberWithInt:retval]]; | |
1266 } | |
1267 -(void)setUserInterfaceStyle:(id)param | |
1268 { | |
1269 NSNumber *number = param; | |
1270 UIUserInterfaceStyle style = [number intValue]; | |
1271 | |
1272 [hiddenWindow setOverrideUserInterfaceStyle:style]; | |
1273 } | |
1236 @end | 1274 @end |
1237 | 1275 |
1238 DWObject *DWObj; | 1276 DWObject *DWObj; |
1239 | 1277 |
1240 /* Returns TRUE if iOS 12+ is in Dark Mode */ | 1278 /* Returns TRUE if iOS 12+ is in Dark Mode */ |
2238 else /* Otherwise treat it as doubleClicked: */ | 2276 else /* Otherwise treat it as doubleClicked: */ |
2239 { | 2277 { |
2240 /* Handler for container class */ | 2278 /* Handler for container class */ |
2241 _dw_event_handler(self, (UIEvent *)params, 9); | 2279 _dw_event_handler(self, (UIEvent *)params, 9); |
2242 } | 2280 } |
2281 } | |
2282 -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath | |
2283 { | |
2284 if([self allowsMultipleSelection]) | |
2285 [self tableView:tableView didSelectRowAtIndexPath:indexPath]; | |
2243 } | 2286 } |
2244 -(DWMenu *)menuForEvent:(UIEvent *)event | 2287 -(DWMenu *)menuForEvent:(UIEvent *)event |
2245 { | 2288 { |
2246 #if 0 /* TODO: Fix this */ | 2289 #if 0 /* TODO: Fix this */ |
2247 int row; | 2290 int row; |
10625 return DW_FEATURE_ENABLED; | 10668 return DW_FEATURE_ENABLED; |
10626 case DW_FEATURE_DARK_MODE: | 10669 case DW_FEATURE_DARK_MODE: |
10627 { | 10670 { |
10628 if(DWObj) | 10671 if(DWObj) |
10629 { | 10672 { |
10630 UIUserInterfaceStyle style = [[DWObj hiddenWindow] overrideUserInterfaceStyle]; | 10673 NSMutableArray *array = [[NSMutableArray alloc] init]; |
10631 | 10674 int retval = DW_FEATURE_UNSUPPORTED; |
10632 switch(style) | 10675 NSNumber *number; |
10633 { | 10676 |
10634 case UIUserInterfaceStyleLight: | 10677 [DWObj safeCall:@selector(getUserInterfaceStyle:) withObject:array]; |
10635 return DW_DARK_MODE_DISABLED; | 10678 number = [array lastObject]; |
10636 case UIUserInterfaceStyleDark: | 10679 if(number) |
10637 return DW_DARK_MODE_FORCED; | 10680 retval = [number intValue]; |
10638 default: /* UIUserInterfaceStyleUnspecified */ | 10681 return retval; |
10639 style = [[[[DWObj hiddenWindow] rootViewController] traitCollection] userInterfaceStyle]; | |
10640 } | |
10641 switch(style) | |
10642 { | |
10643 case UIUserInterfaceStyleLight: | |
10644 return DW_DARK_MODE_BASIC; | |
10645 case UIUserInterfaceStyleDark: | |
10646 return DW_DARK_MODE_FULL; | |
10647 default: /* UIUserInterfaceStyleUnspecified */ | |
10648 return DW_FEATURE_UNSUPPORTED; | |
10649 } | |
10650 } | 10682 } |
10651 return _dw_dark_mode_state; | 10683 return _dw_dark_mode_state; |
10652 } | 10684 } |
10653 default: | 10685 default: |
10654 return DW_FEATURE_UNSUPPORTED; | 10686 return DW_FEATURE_UNSUPPORTED; |
10686 /* Make sure DWObj is initialized */ | 10718 /* Make sure DWObj is initialized */ |
10687 if(DWObj) | 10719 if(DWObj) |
10688 { | 10720 { |
10689 /* Disabled forces the non-dark aqua theme */ | 10721 /* Disabled forces the non-dark aqua theme */ |
10690 if(state == DW_FEATURE_DISABLED) | 10722 if(state == DW_FEATURE_DISABLED) |
10691 [[DWObj hiddenWindow] setOverrideUserInterfaceStyle:UIUserInterfaceStyleLight]; | 10723 [DWObj safeCall:@selector(setUserInterfaceStyle:) withObject:[NSNumber numberWithInt:UIUserInterfaceStyleLight]]; |
10692 /* Enabled lets the OS decide the mode */ | 10724 /* Enabled lets the OS decide the mode */ |
10693 else if(state == DW_FEATURE_ENABLED || state == DW_DARK_MODE_FULL) | 10725 else if(state == DW_FEATURE_ENABLED || state == DW_DARK_MODE_FULL) |
10694 [[DWObj hiddenWindow] setOverrideUserInterfaceStyle:UIUserInterfaceStyleUnspecified]; | 10726 [DWObj safeCall:@selector(setUserInterfaceStyle:) withObject:[NSNumber numberWithInt:UIUserInterfaceStyleUnspecified]]; |
10695 /* 2 forces dark mode aqua appearance */ | 10727 /* 2 forces dark mode aqua appearance */ |
10696 else if(state == DW_DARK_MODE_FORCED) | 10728 else if(state == DW_DARK_MODE_FORCED) |
10697 [[DWObj hiddenWindow] setOverrideUserInterfaceStyle:UIUserInterfaceStyleDark]; | 10729 [DWObj safeCall:@selector(setUserInterfaceStyle:) withObject:[NSNumber numberWithInt:UIUserInterfaceStyleDark]]; |
10698 } | 10730 } |
10699 else /* Save the requested state for dw_init() */ | 10731 else /* Save the requested state for dw_init() */ |
10700 _dw_dark_mode_state = state; | 10732 _dw_dark_mode_state = state; |
10701 } | 10733 } |
10702 default: | 10734 default: |