Refs #1530. Fixed: table views could not be interacted with if they couldn't become the first responder.

This commit is contained in:
Alexander Ljungberg committed 2012-08-01 18:59:54 +01:00
1 parent 7537f4d032
commit 31ab70d6fc
3 files changed
+59 -22

No files matched your search

+35 -13
View File
@@ -4,6 +4,7 @@
@implementation CPTableViewTest : OJTestCase
{
CPWindow theWindow;
CPTableView tableView;
CPTableColumn tableColumn;
@@ -15,19 +16,21 @@
- (void)setUp
{
// setup a reasonable table
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1024.0, 768.0)
styleMask:CPWindowNotSizable];
tableView = [[FirstResponderConfigurableTableView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
tableColumn = [[CPTableColumn alloc] initWithIdentifier:@"Foo"];
tableView.acceptsFirstResponder = YES;
[tableView addTableColumn:tableColumn];
[[theWindow contentView] addSubview:tableView];
}
- (void)testDoubleAction
{
doubleActionReceived = NO;
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1024.0, 768.0)
styleMask:CPWindowNotSizable];
[[theWindow contentView] addSubview:tableView];
[tableView setTarget:self];
[tableView setDoubleAction:@selector(doubleAction:)];
@@ -44,6 +47,20 @@
[tableView trackMouse:dblClkUp];
[self assertTrue:doubleActionReceived];
// The event should also work even if the table is not the first responder.
tableView.acceptsFirstResponder = NO;
[theWindow makeFirstResponder:nil];
doubleActionReceived = NO;
[[CPApplication sharedApplication] sendEvent:dblClkDown];
[tableView trackMouse:dblClkDown];
[[CPApplication sharedApplication] sendEvent:dblClkUp];
[tableView trackMouse:dblClkUp];
[self assertTrue:doubleActionReceived];
}
- (void)doubleAction:(id)sender
@@ -124,11 +141,6 @@
*/
- (void)testEditCell
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 200, 150)
styleMask:CPWindowNotSizable];
[[theWindow contentView] addSubview:tableView];
var dataSource = [TestDataSource new];
[dataSource setTableEntries:["A", "B", "C"]];
@@ -230,9 +242,7 @@
- (void)testContentBinding
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 200, 150)
styleMask:CPWindowNotSizable],
contentBindingTable = [[CPTableView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)],
var contentBindingTable = [[CPTableView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)],
tableColumn = [[CPTableColumn alloc] initWithIdentifier:@"A"],
delegate = [ContentBindingTableDelegate new];
@@ -259,6 +269,18 @@
@end
@implementation FirstResponderConfigurableTableView : CPTableView
{
BOOL acceptsFirstResponder;
}
- (BOOL)acceptsFirstResponder
{
return acceptsFirstResponder;
}
@end
@implementation TestDataSource : CPObject
{
CPArray tableEntries @accessors;