changeset 2464:4fba0b9453ee

iOS: Fix calculating label size when there is no text. Use "gT" to calculate the height. Fix some menu tests, they were using old classes or disabled code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 14 Apr 2021 21:35:21 +0000
parents 79c7bf492bc1
children 79732eb2deef
files ios/dw.m
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Wed Apr 14 20:53:46 2021 +0000
+++ b/ios/dw.m	Wed Apr 14 21:35:21 2021 +0000
@@ -2111,6 +2111,7 @@
         config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu"
                                                          previewProvider:nil
                                                           actionProvider:^(NSArray* suggestedAction){return popupmenu;}];
+        [window setPopupMenu:nil];
     }
     return config;
 }
@@ -3722,11 +3723,12 @@
     /* If we have a string...
      * calculate the size with the current font.
      */
-    if(nsstr && [nsstr length])
+    if(nsstr)
     {
         int textwidth, textheight;
 
-        dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &textwidth, &textheight);
+        /* If we have an empty string, use "gT" to get the most height for the font */
+        dw_font_text_extents_get(object, NULL, [nsstr length] ? (char *)[nsstr UTF8String] : "gT", &textwidth, &textheight);
 
         if(textheight > thisheight)
             thisheight = textheight;
@@ -8566,7 +8568,7 @@
         NSArray *subviews = [sv subviews];
         object = [subviews firstObject];
     }
-    if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[UIMenuItem class]])
+    if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWMenuItem class]])
     {
         [object setEnabled:NO];
     }
@@ -8598,7 +8600,7 @@
         NSArray *subviews = [sv subviews];
         object = [subviews firstObject];
     }
-    if([object isKindOfClass:[UIControl class]] /* TODO: || [object isKindOfClass:[UIMenuItem class]] */)
+    if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWMenuItem class]])
     {
         [object setEnabled:YES];
     }