mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-30 15:33:35 +00:00
Refs #1530. Fixed: table views could not be interacted with if they couldn't become the first responder.
This commit is contained in:
@@ -4037,8 +4037,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
*/
|
||||
- (BOOL)startTrackingAt:(CGPoint)aPoint
|
||||
{
|
||||
if (![[self window] makeFirstResponder:self])
|
||||
return NO;
|
||||
// Try to become the first responder, but if we can't, that's okay.
|
||||
[[self window] makeFirstResponder:self];
|
||||
|
||||
var row = [self rowAtPoint:aPoint];
|
||||
|
||||
@@ -4189,9 +4189,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
*/
|
||||
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
|
||||
{
|
||||
if ([[self window] firstResponder] !== self)
|
||||
return;
|
||||
|
||||
_isSelectingSession = NO;
|
||||
|
||||
var CLICK_TIME_DELTA = 1000,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -10,6 +10,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
CPImage iconImage;
|
||||
CPArray dataSet1;
|
||||
CPArray dataSet2;
|
||||
CPArray dataSet3;
|
||||
|
||||
CPTableColumn randomColumn;
|
||||
}
|
||||
@@ -28,9 +29,15 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
}
|
||||
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,700,500) styleMask:CPClosableWindowMask],
|
||||
contentView = [theWindow contentView];
|
||||
contentView = [theWindow contentView],
|
||||
label = [CPTextField new];
|
||||
|
||||
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 400.0)];
|
||||
[label setStringValue:@"This table refuses to become the first responder but can still be interacted with."];
|
||||
[label sizeToFit];
|
||||
[label setFrameOrigin:CGPointMake(200, 10)]
|
||||
[contentView addSubview:label];
|
||||
|
||||
tableView = [[CUTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 400.0)];
|
||||
|
||||
[tableView setAllowsMultipleSelection:YES];
|
||||
[tableView setAllowsColumnSelection:YES];
|
||||
@@ -172,7 +179,6 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)newWindow
|
||||
{
|
||||
|
||||
var window2 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
|
||||
|
||||
tableView2 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];
|
||||
@@ -186,7 +192,6 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[tableView2 setDelegate:self];
|
||||
[tableView2 setDataSource:self];
|
||||
|
||||
|
||||
var checkBox = [[CPCheckBox alloc] initWithFrame:CGRectMake(5,3,24,24)],
|
||||
checkBoxColumn = [[CPTableColumn alloc] initWithIdentifier:@"checkBox"];
|
||||
[checkBoxColumn setDataView:checkBox];
|
||||
@@ -475,3 +480,16 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CUTableView : CPTableView
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user