changeset 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
files ios/dw.m
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Mon Jul 12 21:51:12 2021 +0000
+++ b/ios/dw.m	Mon Jul 12 23:51:38 2021 +0000
@@ -656,7 +656,7 @@
 @end
 
 API_AVAILABLE(ios(13.0))
-@interface DWMenuItem : UIKeyCommand
+@interface DWMenuItem : UIAction
 {
     BOOL check, enabled;
     unsigned long tag;
@@ -7605,7 +7605,7 @@
 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux)
 {
     DWMenu *menu = menux;
-    DWMenuItem *item = nil;
+    __block DWMenuItem *item = nil;
     if(!title || strlen(title) == 0)
         [menu addItem:[[NSNull alloc] init]];
     else
@@ -7620,11 +7620,10 @@
         nstr = [NSString stringWithUTF8String:newtitle];
         free(newtitle);
 
-        item = [[DWMenuItem commandWithTitle:nstr image:nil
-                                      action:@selector(menuHandler:)
-                                       input:[NSString stringWithUTF8String:accel]
-                               modifierFlags:UIKeyModifierCommand
-                                propertyList:nil] autorelease];
+        item = [[DWMenuItem actionWithTitle:nstr image:nil identifier:nil
+                                    handler:^(__kindof UIAction * _Nonnull action) {
+            [DWObj menuHandler:item];
+        }] autorelease];
         /* Don't set the tag if the ID is 0 or -1 */
         if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP)
             [item setTag:itemid];