Mercurial > dwindows
comparison ios/dw.m @ 2598:4a5364fe65b7
iOS: Add some code to include DWViewController in the UIResponder chain.
Also add a function to display the responder chain... this is debug code but
I want to have it in the repository for now, until I get the problem fixed.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 31 May 2021 21:59:09 +0000 |
parents | cc2befdc97e8 |
children | 32728f6f7ccd |
comparison
equal
deleted
inserted
replaced
2597:99fdcb7f2a2a | 2598:4a5364fe65b7 |
---|---|
267 int _dw_remove_userdata(UserData **root, const char *varname, int all); | 267 int _dw_remove_userdata(UserData **root, const char *varname, int all); |
268 int _dw_main_iteration(NSDate *date); | 268 int _dw_main_iteration(NSDate *date); |
269 CGContextRef _dw_draw_context(id image, bool antialias); | 269 CGContextRef _dw_draw_context(id image, bool antialias); |
270 typedef id (*DWIMP)(id, SEL, ...); | 270 typedef id (*DWIMP)(id, SEL, ...); |
271 | 271 |
272 void _dw_display_responder_chain(id window) | |
273 { | |
274 NSLog(@"=== Starting responder chain dump ===\n"); | |
275 do { | |
276 NSLog(@"%@\n", [window description]); | |
277 } while((window = [window nextResponder])); | |
278 NSLog(@"=== Responder chain dump complete ===\n"); | |
279 } | |
280 | |
272 /* Internal function to queue a window redraw */ | 281 /* Internal function to queue a window redraw */ |
273 void _dw_redraw(id window, int skip) | 282 void _dw_redraw(id window, int skip) |
274 { | 283 { |
275 static id lastwindow = nil; | 284 static id lastwindow = nil; |
276 id redraw = lastwindow; | 285 id redraw = lastwindow; |
1287 CGSize oldsize; | 1296 CGSize oldsize; |
1288 } | 1297 } |
1289 -(BOOL)windowShouldClose:(id)sender; | 1298 -(BOOL)windowShouldClose:(id)sender; |
1290 -(void)windowDidBecomeMain:(id)sender; | 1299 -(void)windowDidBecomeMain:(id)sender; |
1291 -(void)menuHandler:(id)sender; | 1300 -(void)menuHandler:(id)sender; |
1301 -(UIResponder *)nextResponder; | |
1292 @end | 1302 @end |
1293 | 1303 |
1294 @implementation DWView | 1304 @implementation DWView |
1295 -(BOOL)windowShouldClose:(id)sender | 1305 -(BOOL)windowShouldClose:(id)sender |
1296 { | 1306 { |
1337 } | 1347 } |
1338 -(void)menuHandler:(id)sender | 1348 -(void)menuHandler:(id)sender |
1339 { | 1349 { |
1340 [DWObj menuHandler:sender]; | 1350 [DWObj menuHandler:sender]; |
1341 } | 1351 } |
1352 -(UIResponder *)nextResponder { return [[self window] rootViewController]; } | |
1342 @end | 1353 @end |
1343 | 1354 |
1344 @interface DWViewController : UIViewController | 1355 @interface DWViewController : UIViewController |
1345 -(void)viewWillLayoutSubviews; | 1356 -(void)viewWillLayoutSubviews; |
1357 -(UIResponder *)nextResponder; | |
1346 @end | 1358 @end |
1347 | 1359 |
1348 | 1360 |
1349 @implementation DWViewController : UIViewController {} | 1361 @implementation DWViewController : UIViewController {} |
1350 -(void)viewWillLayoutSubviews | 1362 -(void)viewWillLayoutSubviews |
1401 frame.size.height -= 24; | 1413 frame.size.height -= 24; |
1402 frame.origin.y += sbheight; | 1414 frame.origin.y += sbheight; |
1403 [view setFrame:frame]; | 1415 [view setFrame:frame]; |
1404 [view windowResized:frame.size]; | 1416 [view windowResized:frame.size]; |
1405 } | 1417 } |
1418 -(UIResponder *)nextResponder { return [[self viewIfLoaded] window]; } | |
1406 @end | 1419 @end |
1407 | 1420 |
1408 #define _DW_BUTTON_TYPE_NORMAL 0 | 1421 #define _DW_BUTTON_TYPE_NORMAL 0 |
1409 #define _DW_BUTTON_TYPE_CHECK 1 | 1422 #define _DW_BUTTON_TYPE_CHECK 1 |
1410 #define _DW_BUTTON_TYPE_RADIO 2 | 1423 #define _DW_BUTTON_TYPE_RADIO 2 |
2083 _dw_event_handler(self, (id)params, 10); | 2096 _dw_event_handler(self, (id)params, 10); |
2084 | 2097 |
2085 if(window) | 2098 if(window) |
2086 { | 2099 { |
2087 __block UIMenu *popupmenu = [[window popupMenu] menu]; | 2100 __block UIMenu *popupmenu = [[window popupMenu] menu]; |
2101 _dw_display_responder_chain(tableView); | |
2088 config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu" | 2102 config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu" |
2089 previewProvider:nil | 2103 previewProvider:nil |
2090 actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; | 2104 actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; |
2091 [window setPopupMenu:nil]; | 2105 [window setPopupMenu:nil]; |
2092 } | 2106 } |
7940 * Parameters: | 7954 * Parameters: |
7941 * owner: The Owner's window handle or HWND_DESKTOP. | 7955 * owner: The Owner's window handle or HWND_DESKTOP. |
7942 * title: The Window title. | 7956 * title: The Window title. |
7943 * flStyle: Style flags, see the PM reference. | 7957 * flStyle: Style flags, see the PM reference. |
7944 */ | 7958 */ |
7945 DW_FUNCTION_DEFINITION(dw_window_new, HWND, DW_UNUSED(HWND hwndOwner), const char *title, DW_UNUSED(ULONG flStyle)) | 7959 DW_FUNCTION_DEFINITION(dw_window_new, HWND, DW_UNUSED(HWND hwndOwner), const char *title, ULONG flStyle) |
7946 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle) | 7960 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle) |
7947 DW_FUNCTION_RETURN(dw_window_new, HWND) | 7961 DW_FUNCTION_RETURN(dw_window_new, HWND) |
7948 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(hwndOwner), HWND, title, char *, DW_UNUSED(flStyle), ULONG) | 7962 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(hwndOwner), HWND, title, char *, flStyle, ULONG) |
7949 { | 7963 { |
7950 DW_FUNCTION_INIT; | 7964 DW_FUNCTION_INIT; |
7951 CGRect screenrect = [[UIScreen mainScreen] bounds]; | 7965 CGRect screenrect = [[UIScreen mainScreen] bounds]; |
7952 DWWindow *window = [[DWWindow alloc] initWithFrame:screenrect]; | 7966 DWWindow *window = [[DWWindow alloc] initWithFrame:screenrect]; |
7953 DWView *view = [[DWView alloc] init]; | 7967 DWView *view = [[DWView alloc] init]; |
7956 [window setWindowLevel:UIWindowLevelNormal]; | 7970 [window setWindowLevel:UIWindowLevelNormal]; |
7957 [window setRootViewController:[[DWViewController alloc] init]]; | 7971 [window setRootViewController:[[DWViewController alloc] init]]; |
7958 [window addSubview:view]; | 7972 [window addSubview:view]; |
7959 [window setBackgroundColor:[UIColor systemBackgroundColor]]; | 7973 [window setBackgroundColor:[UIColor systemBackgroundColor]]; |
7960 | 7974 |
7961 /* TODO: Handle style flags... if we can? There is no visible frame */ | 7975 /* Handle style flags... There is no visible frame... |
7976 * On iOS 13 and higher if a titlebar is requested create a navigation bar. | |
7977 */ | |
7962 if(@available(iOS 13.0, *)) { | 7978 if(@available(iOS 13.0, *)) { |
7963 NSString *nstitle = [NSString stringWithUTF8String:title]; | 7979 NSString *nstitle = [NSString stringWithUTF8String:title]; |
7964 [window setLargeContentTitle:nstitle]; | 7980 [window setLargeContentTitle:nstitle]; |
7965 if(flStyle & DW_FCF_TITLEBAR) | 7981 if(flStyle & DW_FCF_TITLEBAR) |
7966 { | 7982 { |