# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1626166282 0 # Node ID d60a44a27d70e26184c076df5422284c0e6e9ee9 # Parent 4671ac4ad3c6e7c49232df3a400fcb19a0105789 iOS: Implement menu separators using inline UIMenus. diff -r 4671ac4ad3c6 -r d60a44a27d70 ios/dw.m --- a/ios/dw.m Mon Jul 12 23:51:38 2021 +0000 +++ b/ios/dw.m Tue Jul 13 08:51:22 2021 +0000 @@ -1557,6 +1557,7 @@ /* Create or recreate the UIMenu recursively */ UIMenu *oldmenu = menu; NSMutableArray *menuchildren = [[NSMutableArray alloc] init]; + NSMutableArray *section = menuchildren; for(id child in children) { @@ -1566,10 +1567,35 @@ DWMenu *submenu = [menuitem submenu]; if(submenu) - [menuchildren addObject:[submenu menu]]; + [section addObject:[submenu menu]]; else - [menuchildren addObject:child]; - } + [section addObject:child]; + } + /* NSNull entry tells us to make a new section... + * we do this by making a new UIMenu inline. + */ + else if([child isMemberOfClass:[NSNull class]]) + { + if(section != menuchildren) + { + UIMenu *sectionmenu = [UIMenu menuWithTitle:@"" + image:nil + identifier:nil + options:UIMenuOptionsDisplayInline + children:section]; + [menuchildren addObject:sectionmenu]; + } + section = [[NSMutableArray alloc] init]; + } + } + if(section != menuchildren) + { + UIMenu *sectionmenu = [UIMenu menuWithTitle:@"" + image:nil + identifier:nil + options:UIMenuOptionsDisplayInline + children:section]; + [menuchildren addObject:sectionmenu]; } if(title) {