mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-02 00:43:35 +00:00
Previously the method shouldSelectRow was called even it's the method selectionIndexesForProposedSelection was implemented by the delegate. Now it works as in Cocoa. The method selectionIndexesForProposedSelection is called when it has to be called, like in Cocoa. This PR adds new methods to check and call the delegate/datasource methods more easily Test app in Tests/Manual/TableTest/DelegateSelectionTest/
129 lines
3.0 KiB
Plaintext
Executable File
129 lines
3.0 KiB
Plaintext
Executable File
/*
|
|
* AppController.j
|
|
* DelegateSelectionTest
|
|
*
|
|
* Created by You on October 16, 2013.
|
|
* Copyright 2013, Your Company All rights reserved.
|
|
*/
|
|
|
|
@import <Foundation/Foundation.j>
|
|
@import <AppKit/AppKit.j>
|
|
|
|
|
|
@implementation AppController : CPObject
|
|
{
|
|
CPArray _names;
|
|
|
|
@outlet CPWindow theWindow;
|
|
@outlet CPTableView tableView;
|
|
@outlet CPTableView secondTableView;
|
|
}
|
|
|
|
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
|
{
|
|
// This is called when the application is done loading.
|
|
|
|
}
|
|
|
|
- (void)awakeFromCib
|
|
{
|
|
// This is called when the cib is done loading.
|
|
// You can implement this method on any object instantiated from a Cib.
|
|
// It's a useful hook for setting up current UI values, and other things.
|
|
_names = [@"Alexandre Wilhelm", @"Alexander Ljungberg", @"Antoine Mercadal", @"Aparajita Fishman"];
|
|
[tableView setAllowsMultipleSelection:YES];
|
|
[tableView reloadData];
|
|
|
|
[secondTableView setDelegate:[DelegateSecondTableView new]];
|
|
[secondTableView reloadData];
|
|
|
|
// In this case, we want the window from Cib to become our full browser window
|
|
[theWindow setFullPlatformWindow:YES];
|
|
}
|
|
|
|
- (int)numberOfRowsInTableView:(CPTableView)aTableView
|
|
{
|
|
return [_names count];
|
|
}
|
|
|
|
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRowIndex
|
|
{
|
|
return _names[aRowIndex];
|
|
}
|
|
|
|
- (void)tableViewSelectionDidChange:(CPNotification)aNotification
|
|
{
|
|
console.log(@"tableViewSelectionDidChange")
|
|
}
|
|
|
|
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
|
|
{
|
|
console.log(@"selectionShouldChangeInTableView")
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
|
|
{
|
|
console.log(@"shouldSelectRow");
|
|
return YES;
|
|
}
|
|
|
|
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification
|
|
{
|
|
console.log(@"tableViewSelectionIsChanging");
|
|
}
|
|
|
|
- (void)tableView:(CPTableView)tableView didClickTableColumn:(CPTableColumn)tableColumn;
|
|
{
|
|
console.log(@"didClickTableColumn");
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation DelegateSecondTableView : CPObject
|
|
{
|
|
}
|
|
|
|
- (id)init
|
|
{
|
|
if (self = [super init])
|
|
{
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (CPIndexSet)tableView:(CPTableView)tableView selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes
|
|
{
|
|
console.log(@"selectionIndexesForProposedSelection")
|
|
return proposedSelectionIndexes;
|
|
}
|
|
|
|
- (void)tableViewSelectionDidChange:(CPNotification)aNotification
|
|
{
|
|
console.log(@"tableViewSelectionDidChange")
|
|
}
|
|
|
|
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
|
|
{
|
|
console.log(@"selectionShouldChangeInTableView")
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
|
|
{
|
|
console.log(@"shouldSelectRow");
|
|
return YES;
|
|
}
|
|
|
|
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification
|
|
{
|
|
console.log(@"tableViewSelectionIsChanging");
|
|
}
|
|
|
|
- (void)tableView:(CPTableView)tableView didClickTableColumn:(CPTableColumn)tableColumn;
|
|
{
|
|
console.log(@"didClickTableColumn");
|
|
}
|
|
|
|
@end
|