Fixed cell editing in table on OS X.

This commit is contained in:
Pietro Gagliardi 2016-06-26 00:44:21 -04:00
parent 2f9a38b5fe
commit 15eca1372e
1 changed files with 7 additions and 2 deletions

View File

@ -7,7 +7,6 @@
// - background color shows up for a line or two below selection // - background color shows up for a line or two below selection
// - editable NSTextFields have no intrinsic width // - editable NSTextFields have no intrinsic width
// - changing a part property does not refresh views // - changing a part property does not refresh views
// - the target/action thing is wrong; we need to pass the model column for col, not the view column
@interface tableModel : NSObject<NSTableViewDataSource, NSTableViewDelegate> { @interface tableModel : NSObject<NSTableViewDataSource, NSTableViewDelegate> {
uiTableModel *libui_m; uiTableModel *libui_m;
@ -22,6 +21,7 @@ enum {
}; };
@interface tablePart : NSObject @interface tablePart : NSObject
@property int index;
@property int type; @property int type;
@property int textColumn; @property int textColumn;
@property int textColorColumn; @property int textColorColumn;
@ -184,8 +184,9 @@ done:
else else
implbug("table model editing action triggered on non-editable view"); implbug("table model editing action triggered on non-editable view");
// note the use of [view tag] we need the model column, which we store in the view tag for relevant views below
(*(m->mh->SetCellValue))(m->mh, m, (*(m->mh->SetCellValue))(m->mh, m,
row, [tv columnForView:view], row, [view tag],
data); data);
// always refresh the value in case the model rejected it // always refresh the value in case the model rejected it
// TODO only affect tv // TODO only affect tv
@ -234,6 +235,7 @@ done:
[tf setTarget:m->m]; [tf setTarget:m->m];
[tf setAction:@selector(onAction:)]; [tf setAction:@selector(onAction:)];
} }
[tf setTag:self.index];
view = tf; view = tf;
break; break;
case partImage: case partImage:
@ -250,6 +252,7 @@ done:
iv, NSLayoutAttributeHeight, iv, NSLayoutAttributeHeight,
1, 0, 1, 0,
@"uiTable image squareness constraint")]; @"uiTable image squareness constraint")];
[iv setTag:self.index];
view = iv; view = iv;
break; break;
} }
@ -348,6 +351,7 @@ void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
tablePart *part; tablePart *part;
part = [tablePart new]; part = [tablePart new];
part.index = [c->parts count];
part.type = partText; part.type = partText;
part.textColumn = modelColumn; part.textColumn = modelColumn;
part.expand = expand; part.expand = expand;
@ -359,6 +363,7 @@ void uiTableColumnAppendImagePart(uiTableColumn *c, int modelColumn, int expand)
tablePart *part; tablePart *part;
part = [tablePart new]; part = [tablePart new];
part.index = [c->parts count];
part.type = partImage; part.type = partImage;
part.imageColumn = modelColumn; part.imageColumn = modelColumn;
part.expand = expand; part.expand = expand;