comparison 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
comparison
equal deleted inserted replaced
2831:adb0e4ce9347 2832:df16bb0a11b2
2342 } 2342 }
2343 -(void)setColumnData:(NSMutableArray *)input; 2343 -(void)setColumnData:(NSMutableArray *)input;
2344 -(NSMutableArray *)columnData; 2344 -(NSMutableArray *)columnData;
2345 -(UIImageView *)image; 2345 -(UIImageView *)image;
2346 -(UILabel *)label; 2346 -(UILabel *)label;
2347 -(void)columnClicked:(id)sender;
2347 @end 2348 @end
2348 2349
2349 @implementation DWTableViewCell 2350 @implementation DWTableViewCell
2350 -(id)init { 2351 -(id)init {
2351 self = [super init]; 2352 self = [super init];
2384 ]]; 2385 ]];
2385 return self; 2386 return self;
2386 } 2387 }
2387 -(UILabel *)label { return label; } 2388 -(UILabel *)label { return label; }
2388 -(UIImageView *)image { return image; } 2389 -(UIImageView *)image { return image; }
2390 -(void)columnClicked:(id)sender
2391 {
2392 if([sender isMemberOfClass:[UIButton class]])
2393 {
2394 id view = [self superview];
2395
2396 while(view && [view isKindOfClass:[UITableView class]] == NO)
2397 view = [view superview];
2398
2399 _dw_event_handler(view, DW_INT_TO_POINTER([sender tag]+1), _DW_EVENT_COLUMN_CLICK);
2400 }
2401 }
2389 -(void)setColumnData:(NSMutableArray *)input 2402 -(void)setColumnData:(NSMutableArray *)input
2390 { 2403 {
2391 if(columndata != input) 2404 if(columndata != input)
2392 { 2405 {
2393 NSMutableArray *olddata = columndata; 2406 NSMutableArray *olddata = columndata;
2427 } 2440 }
2428 if(!label) 2441 if(!label)
2429 { 2442 {
2430 label = extra ? [[UILabel alloc] init] : [UIButton buttonWithType:UIButtonTypeCustom]; 2443 label = extra ? [[UILabel alloc] init] : [UIButton buttonWithType:UIButtonTypeCustom];
2431 2444
2445 [label setTag:index];
2432 [label setTranslatesAutoresizingMaskIntoConstraints:NO]; 2446 [label setTranslatesAutoresizingMaskIntoConstraints:NO];
2433 if(extra) 2447 if(extra)
2434 [label setTextAlignment:NSTextAlignmentCenter]; 2448 [label setTextAlignment:NSTextAlignmentCenter];
2449 else
2450 {
2451 [label addTarget:self action:@selector(columnClicked:)
2452 forControlEvents:UIControlEventTouchUpInside];
2453 [label setTitleColor:[UIColor darkTextColor] forState:UIControlStateNormal];
2454 }
2435 2455
2436 if(index < [subviews count]) 2456 if(index < [subviews count])
2437 [stack insertArrangedSubview:label atIndex:index]; 2457 [stack insertArrangedSubview:label atIndex:index];
2438 else /* Remove the view if it won't work */ 2458 else /* Remove the view if it won't work */
2439 [stack addArrangedSubview:label]; 2459 [stack addArrangedSubview:label];
2461 } 2481 }
2462 if(!image) 2482 if(!image)
2463 { 2483 {
2464 image = [[UIImageView alloc] init]; 2484 image = [[UIImageView alloc] init];
2465 2485
2486 [image setTag:index];
2466 [image setTranslatesAutoresizingMaskIntoConstraints:NO]; 2487 [image setTranslatesAutoresizingMaskIntoConstraints:NO];
2467 2488
2468 if(index < [subviews count]) 2489 if(index < [subviews count])
2469 [stack insertArrangedSubview:image atIndex:index]; 2490 [stack insertArrangedSubview:image atIndex:index];
2470 else 2491 else