comparison ios/dw.m @ 2769:06f45ee90e0f

iOS: dw_tree_get_parent() should return NULL for the root node. I missed implementing dw_tree_item_select() so, implmented now. Always return NO to the canEditTreeItem unless we have a delegate that returns YES. This prevents the swipe left to delete happening.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 10 Apr 2022 15:42:18 +0000
parents de144e0fbdf1
children f42d78f136b6
comparison
equal deleted inserted replaced
2768:b17197a2fb28 2769:06f45ee90e0f
3023 -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 3023 -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
3024 { 3024 {
3025 DWTreeItem *treeItem = [self treeItemForIndexPath:indexPath]; 3025 DWTreeItem *treeItem = [self treeItemForIndexPath:indexPath];
3026 if([_treeViewDelegate respondsToSelector:@selector(treeView:canEditTreeItem:)]) 3026 if([_treeViewDelegate respondsToSelector:@selector(treeView:canEditTreeItem:)])
3027 return [_treeViewDelegate treeView:self canEditTreeItem:treeItem]; 3027 return [_treeViewDelegate treeView:self canEditTreeItem:treeItem];
3028 else 3028 return NO;
3029 return (treeItem.isRoot == NO);
3030 } 3029 }
3031 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 3030 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
3032 { 3031 {
3033 DWTreeItem *treeItem = [self treeItemForIndexPath:indexPath]; 3032 DWTreeItem *treeItem = [self treeItemForIndexPath:indexPath];
3034 if(editingStyle == UITableViewCellEditingStyleDelete) 3033 if(editingStyle == UITableViewCellEditingStyleDelete)
6661 DW_FUNCTION_INIT; 6660 DW_FUNCTION_INIT;
6662 DWTreeItem *treeparent = nil; 6661 DWTreeItem *treeparent = nil;
6663 DWTreeItem *treeitem = item; 6662 DWTreeItem *treeitem = item;
6664 if(treeitem) 6663 if(treeitem)
6665 treeparent = treeitem.parent; 6664 treeparent = treeitem.parent;
6665 if(treeparent && [treeparent isRoot])
6666 treeparent = NULL;
6666 DW_FUNCTION_RETURN_THIS(treeparent); 6667 DW_FUNCTION_RETURN_THIS(treeparent);
6667 } 6668 }
6668 6669
6669 /* 6670 /*
6670 * Sets the text and icon of an item in a tree window (widget). 6671 * Sets the text and icon of an item in a tree window (widget).
6733 * Sets this item as the active selection. 6734 * Sets this item as the active selection.
6734 * Parameters: 6735 * Parameters:
6735 * handle: Handle to the tree window (widget) to be selected. 6736 * handle: Handle to the tree window (widget) to be selected.
6736 * item: Handle to the item to be selected. 6737 * item: Handle to the item to be selected.
6737 */ 6738 */
6738 void API dw_tree_item_select(HWND handle, HTREEITEM item) 6739 DW_FUNCTION_DEFINITION(dw_tree_item_select, void, HWND handle, HTREEITEM item)
6739 { 6740 DW_FUNCTION_ADD_PARAM2(handle, item)
6740 /* TODO: Implement tree for iOS if possible */ 6741 DW_FUNCTION_NO_RETURN(dw_tree_item_select)
6741 } 6742 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6743 {
6744 DW_FUNCTION_INIT;
6745 DWTree *tree = handle;
6746 DWTreeItem *treeitem = item;
6747
6748 if(tree && treeitem)
6749 {
6750 NSInteger itemIndex = [tree treeView:tree rowForTreeItem:treeitem];
6751 if(itemIndex > -1)
6752 {
6753 NSIndexPath *ip = [NSIndexPath indexPathForRow:(NSUInteger)itemIndex inSection:0];
6754
6755 [tree selectRowAtIndexPath:ip
6756 animated:NO
6757 scrollPosition:UITableViewScrollPositionNone];
6758 }
6759 }
6760 DW_FUNCTION_RETURN_NOTHING;
6761 }
6762
6742 6763
6743 /* 6764 /*
6744 * Removes all nodes from a tree. 6765 * Removes all nodes from a tree.
6745 * Parameters: 6766 * Parameters:
6746 * handle: Handle to the window (widget) to be cleared. 6767 * handle: Handle to the window (widget) to be cleared.