diff --git a/redo/future b/redo/future index 0206cb1..d5bcf96 100644 --- a/redo/future +++ b/redo/future @@ -68,3 +68,4 @@ gtk+, mac os x - once that is done, document the behavior of Areas all - make spaced settable somehow + - rename Selected to Selection? diff --git a/redo/objc_darwin.h b/redo/objc_darwin.h index f07180d..f828445 100644 --- a/redo/objc_darwin.h +++ b/redo/objc_darwin.h @@ -93,6 +93,8 @@ extern void tableAppendColumn(id, intptr_t, char *, int, BOOL); extern void tableUpdate(id); extern void tableMakeDataSource(id, void *); extern struct xsize tablePreferredSize(id); +extern intptr_t tableSelected(id); +extern void tableSelect(id, intptr_t); /* control_darwin.m */ extern void parent(id, id); diff --git a/redo/table_darwin.go b/redo/table_darwin.go index 1f889c0..bccaf1b 100644 --- a/redo/table_darwin.go +++ b/redo/table_darwin.go @@ -62,6 +62,18 @@ func (t *table) LoadImageList(i ImageList) { i.apply(&t.images) } +func (t *table) Selected() int { + t.RLock() + defer t.RUnlock() + return int(C.tableSelected(t._id)) +} + +func (t *table) Select(index int) { + t.RLock() + defer t.RUnlock() + C.tableSelect(t._id, C.intptr_t(index)) +} + //export goTableDataSource_getValue func goTableDataSource_getValue(data unsafe.Pointer, row C.intptr_t, col C.intptr_t, outtype *C.int) unsafe.Pointer { t := (*table)(data) diff --git a/redo/table_darwin.m b/redo/table_darwin.m index e3c2192..5fdac83 100644 --- a/redo/table_darwin.m +++ b/redo/table_darwin.m @@ -173,3 +173,15 @@ struct xsize tablePreferredSize(id control) s.height += (intptr_t) [[t headerView] frame].size.height; return s; } + +intptr_t tableSelected(id table) +{ + return (intptr_t) [toNSTableView(table) selectedRow]; +} + +void tableSelect(id table, intptr_t row) +{ + [toNSTableView(table) deselectAll:table]; + if (row != -1) + [toNSTableView(table) selectRowIndexes:[NSIndexSet indexSetWithIndex:((NSUInteger) row)] byExtendingSelection:NO]; +}