Mercurial > dwindows
diff ios/dw.m @ 2832:df16bb0a11b2
iOS: Implement DW_SIGNAL_COLUMN_CLICKED for multi-line containers.
Also set the color of the button text so it is readable.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 11 Sep 2022 08:15:13 +0000 |
parents | adb0e4ce9347 |
children | 1df137a1a4b9 |
line wrap: on
line diff
--- a/ios/dw.m Sat Sep 10 22:03:47 2022 +0000 +++ b/ios/dw.m Sun Sep 11 08:15:13 2022 +0000 @@ -2344,6 +2344,7 @@ -(NSMutableArray *)columnData; -(UIImageView *)image; -(UILabel *)label; +-(void)columnClicked:(id)sender; @end @implementation DWTableViewCell @@ -2386,6 +2387,18 @@ } -(UILabel *)label { return label; } -(UIImageView *)image { return image; } +-(void)columnClicked:(id)sender +{ + if([sender isMemberOfClass:[UIButton class]]) + { + id view = [self superview]; + + while(view && [view isKindOfClass:[UITableView class]] == NO) + view = [view superview]; + + _dw_event_handler(view, DW_INT_TO_POINTER([sender tag]+1), _DW_EVENT_COLUMN_CLICK); + } +} -(void)setColumnData:(NSMutableArray *)input { if(columndata != input) @@ -2429,9 +2442,16 @@ { label = extra ? [[UILabel alloc] init] : [UIButton buttonWithType:UIButtonTypeCustom]; + [label setTag:index]; [label setTranslatesAutoresizingMaskIntoConstraints:NO]; if(extra) [label setTextAlignment:NSTextAlignmentCenter]; + else + { + [label addTarget:self action:@selector(columnClicked:) + forControlEvents:UIControlEventTouchUpInside]; + [label setTitleColor:[UIColor darkTextColor] forState:UIControlStateNormal]; + } if(index < [subviews count]) [stack insertArrangedSubview:label atIndex:index]; @@ -2463,6 +2483,7 @@ { image = [[UIImageView alloc] init]; + [image setTag:index]; [image setTranslatesAutoresizingMaskIntoConstraints:NO]; if(index < [subviews count])