* add support for TableView::onActivate(TableViewCell) to Windows, macOS
** allows the new input/hotkey mapping panels to work on Windows, macOS
* polish BrowserDialog behavior
This commit is contained in:
byuu
2019-08-01 02:40:35 +09:00
parent a7b30b069c
commit bc7456246c
8 changed files with 80 additions and 28 deletions

View File

@@ -110,13 +110,15 @@
tableView->doChange();
}
-(IBAction) activate:(id)sender {
tableView->doActivate({});
}
-(IBAction) doubleAction:(id)sender {
if([content clickedRow] >= 0) {
[self activate:self];
int row = [content clickedRow];
if(row >= 0 && row < tableView->state.items.size()) {
int column = [content clickedColumn];
if(column >= 0 && column < tableView->state.columns.size()) {
auto item = tableView->state.items[row];
auto cell = item->cell(column);
tableView->doActivate(cell);
}
}
}
@@ -127,9 +129,14 @@
-(void) keyDown:(NSEvent*)event {
auto character = [[event characters] characterAtIndex:0];
if(character == NSEnterCharacter || character == NSCarriageReturnCharacter) {
if([self selectedRow] >= 0) {
[[self delegate] activate:self];
return;
int row = [self selectedRow];
if(row >= 0 && row < tableView->state.items.size()) {
int column = max(0, [self selectedColumn]); //can be -1?
if(column >= 0 && column < tableView->state.columns.size()) {
auto item = tableView->state.items[row];
auto cell = item->cell(column);
tableView->doActivate(cell);
}
}
}

View File

@@ -20,7 +20,6 @@
-(NSString*) tableView:(NSTableView*)table toolTipForCell:(NSCell*)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation;
-(void) tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
-(void) tableViewSelectionDidChange:(NSNotification*)notification;
-(IBAction) activate:(id)sender;
-(IBAction) doubleAction:(id)sender;
@end