Mercurial > dwindows
changeset 2792:9c6fdafd10be
iOS: Implement dw_window_get_text() on top-level windows.
Simplify, remove redundant code and remove deprecated code.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 14 Jul 2022 06:02:01 +0000 |
parents | b62859fbd9a3 |
children | 24977a1ec6fc |
files | ios/dw.m |
diffstat | 1 files changed, 22 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ios/dw.m Thu Jul 14 05:44:10 2022 +0000 +++ b/ios/dw.m Thu Jul 14 06:02:01 2022 +0000 @@ -9508,30 +9508,36 @@ DW_FUNCTION_INIT; id object = _dw_text_handle(handle); id control = handle; + NSString *nsstr = nil; char *retval = NULL; if([control isKindOfClass:[UIButton class]]) { - NSString *nsstr = [control titleForState:UIControlStateNormal]; - - retval = strdup([nsstr UTF8String]); + nsstr = [control titleForState:UIControlStateNormal]; } else if([object isKindOfClass:[UILabel class]] || [object isKindOfClass:[UITextField class]]) { - NSString *nsstr = [object text]; - + nsstr = [object text]; + } + else if([object isMemberOfClass:[DWWindow class]]) + { + DWWindow *window = object; + UIView *view = [[window rootViewController] view]; + NSArray *array = [view subviews]; + + for(id obj in array) + { + if([obj isMemberOfClass:[UINavigationBar class]]) + { + UINavigationBar *nav = obj; + UINavigationItem *item = [[nav items] firstObject]; + + nsstr = [item title]; + } + } + } + if(nsstr && [nsstr length] > 0) retval = strdup([nsstr UTF8String]); - } -#ifdef DW_INCLUDE_DEPRECATED - else if([object isKindOfClass:[UIControl class]]) - { - UIControl *control = object; - NSString *nsstr = [control text]; - - if(nsstr && [nsstr length] > 0) - retval = strdup([nsstr UTF8String]); - } -#endif DW_FUNCTION_RETURN_THIS(retval); } @@ -9581,14 +9587,6 @@ } } } -#ifdef DW_INCLUDE_DEPRECATED - else if([object isKindOfClass:[UIControl class]]) - { - UIControl *control = object; - [control setText:[NSString stringWithUTF8String:text]]; - item = _dw_box_item(handle); - } -#endif /* If we changed the text... * Check to see if any of the sizes need to be recalculated */