comparison ios/dw.m @ 2603:592f3003f853

iOS: Switch to using UIKeyCommand for menu items so we can use they keyboard accelerators if there is a hardware keyboard. Also add "..." to submenus.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 12 Jul 2021 21:51:12 +0000
parents cc5013e626f7
children 4671ac4ad3c6
comparison
equal deleted inserted replaced
2602:cc5013e626f7 2603:592f3003f853
654 -(void)removeItem:(id)item; 654 -(void)removeItem:(id)item;
655 -(void)dealloc; 655 -(void)dealloc;
656 @end 656 @end
657 657
658 API_AVAILABLE(ios(13.0)) 658 API_AVAILABLE(ios(13.0))
659 @interface DWMenuItem : UICommand 659 @interface DWMenuItem : UIKeyCommand
660 { 660 {
661 BOOL check, enabled; 661 BOOL check, enabled;
662 unsigned long tag; 662 unsigned long tag;
663 DWMenu *submenu, *menu; 663 DWMenu *submenu, *menu;
664 } 664 }
1570 else 1570 else
1571 [menuchildren addObject:child]; 1571 [menuchildren addObject:child];
1572 } 1572 }
1573 } 1573 }
1574 if(title) 1574 if(title)
1575 menu = [UIMenu menuWithTitle:title children:menuchildren]; 1575 {
1576 menu = [UIMenu menuWithTitle:title image:[UIImage systemImageNamed:@"ellipsis"] identifier:nil
1577 options:0 children:menuchildren];
1578 }
1576 else 1579 else
1577 { 1580 {
1578 if(@available(iOS 14.0, *)) 1581 if(@available(iOS 14.0, *))
1579 menu = [UIMenu menuWithChildren:menuchildren]; 1582 menu = [UIMenu menuWithChildren:menuchildren];
1580 else 1583 else
7617 nstr = [NSString stringWithUTF8String:newtitle]; 7620 nstr = [NSString stringWithUTF8String:newtitle];
7618 free(newtitle); 7621 free(newtitle);
7619 7622
7620 item = [[DWMenuItem commandWithTitle:nstr image:nil 7623 item = [[DWMenuItem commandWithTitle:nstr image:nil
7621 action:@selector(menuHandler:) 7624 action:@selector(menuHandler:)
7625 input:[NSString stringWithUTF8String:accel]
7626 modifierFlags:UIKeyModifierCommand
7622 propertyList:nil] autorelease]; 7627 propertyList:nil] autorelease];
7623 /* Don't set the tag if the ID is 0 or -1 */ 7628 /* Don't set the tag if the ID is 0 or -1 */
7624 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP) 7629 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP)
7625 [item setTag:itemid]; 7630 [item setTag:itemid];
7626 [menu addItem:item]; 7631 [menu addItem:item];