| 55 |
56 |
| 56 _onactivate(&event, _onactivatedata); |
57 _onactivate(&event, _onactivatedata); |
| 57 } |
58 } |
| 58 } |
59 } |
| 59 |
60 |
| |
61 - (void) tableViewSelectionDidChange:(NSNotification *) notification { |
| |
62 if(_onselection) { |
| |
63 UiListSelection sel = ui_tableview_selection(_tableview); |
| |
64 |
| |
65 UiEvent event; |
| |
66 event.obj = _obj; |
| |
67 event.window = event.obj->window; |
| |
68 event.document = event.obj->ctx->document; |
| |
69 event.eventdata = &sel; |
| |
70 event.eventdatatype = UI_EVENT_DATA_LIST_SELECTION; |
| |
71 event.intval = 0; |
| |
72 event.set = ui_get_setop(); |
| |
73 |
| |
74 _onselection(&event, _onselectiondata); |
| |
75 } |
| |
76 } |
| |
77 |
| 60 @end |
78 @end |
| |
79 |
| |
80 UiListSelection ui_tableview_selection(NSTableView *tableview) { |
| |
81 NSIndexSet *indexSet = tableview.selectedRowIndexes; |
| |
82 NSUInteger count = [indexSet count]; |
| |
83 |
| |
84 if(count == 0) { |
| |
85 return (UiListSelection){0, NULL}; |
| |
86 } |
| |
87 |
| |
88 int *rows = calloc(count, sizeof(int)); |
| |
89 |
| |
90 __block NSUInteger i = 0; |
| |
91 [indexSet enumerateIndexesUsingBlock:^(NSUInteger index, BOOL *stop) { |
| |
92 rows[i++] = (int)index; |
| |
93 }]; |
| |
94 |
| |
95 UiListSelection sel; |
| |
96 sel.count = (int)count; |
| |
97 sel.rows = rows; |
| |
98 return sel; |
| |
99 } |