comparison ios/dw.m @ 2604:4671ac4ad3c6

iOS: Had to switch from UIKeyCommand to UIAction for DWMenuItem. UIKeyCommand would be preferable, but it won't add more than one menu item per selector, so we could only have one item on our menus. UIAction allows us to call the selector manually in a closure, but there is no UIKeyAction class that I can find... revisit this later if something changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 12 Jul 2021 23:51:38 +0000
parents 592f3003f853
children d60a44a27d70
comparison
equal deleted inserted replaced
2603:592f3003f853 2604:4671ac4ad3c6
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 : UIKeyCommand 659 @interface DWMenuItem : UIAction
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 }
7603 * submenu: Handle to an existing menu to be a submenu or NULL. 7603 * submenu: Handle to an existing menu to be a submenu or NULL.
7604 */ 7604 */
7605 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux) 7605 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux)
7606 { 7606 {
7607 DWMenu *menu = menux; 7607 DWMenu *menu = menux;
7608 DWMenuItem *item = nil; 7608 __block DWMenuItem *item = nil;
7609 if(!title || strlen(title) == 0) 7609 if(!title || strlen(title) == 0)
7610 [menu addItem:[[NSNull alloc] init]]; 7610 [menu addItem:[[NSNull alloc] init]];
7611 else 7611 else
7612 { 7612 {
7613 char accel[2]; 7613 char accel[2];
7618 accel[1] = 0; 7618 accel[1] = 0;
7619 7619
7620 nstr = [NSString stringWithUTF8String:newtitle]; 7620 nstr = [NSString stringWithUTF8String:newtitle];
7621 free(newtitle); 7621 free(newtitle);
7622 7622
7623 item = [[DWMenuItem commandWithTitle:nstr image:nil 7623 item = [[DWMenuItem actionWithTitle:nstr image:nil identifier:nil
7624 action:@selector(menuHandler:) 7624 handler:^(__kindof UIAction * _Nonnull action) {
7625 input:[NSString stringWithUTF8String:accel] 7625 [DWObj menuHandler:item];
7626 modifierFlags:UIKeyModifierCommand 7626 }] autorelease];
7627 propertyList:nil] autorelease];
7628 /* Don't set the tag if the ID is 0 or -1 */ 7627 /* Don't set the tag if the ID is 0 or -1 */
7629 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP) 7628 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP)
7630 [item setTag:itemid]; 7629 [item setTag:itemid];
7631 [menu addItem:item]; 7630 [menu addItem:item];
7632 7631