• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView


  • Subject: Re: NSTableView
  • From: Lorenzo <email@hidden>
  • Date: Sun, 03 Aug 2003 21:25:15 +0200

Hi,
it's fairly simply.
First of all you have to detect the click in the table header.
I suppose that you already manage the table view through a subclassed
NSObject delegate and that you already have the NSTableView outlet here
called "theList" and the NSMutableArray* here called "listArray" containing
the data of the list. If not, please let me know and I will give you even
the basic info to begin. The following sample works with a list with one
only column. The array must be mutable since you have to sort the array.


// ---------------------------------------------------------
// clickRow
// ---------------------------------------------------------
- (IBAction)clickRow:(id)sender
{
if([theList clickedRow] == -1){
// -1 means the user clicked on the header of the column
[listArray sortUsingFunction:sortList context:nil];
[theList reloadData];
return;
}
}


// ---------------------------------------------------------
// sortList
// ---------------------------------------------------------
int sortList(id left, id right, void *ctxt)
{
return = [left compare:right];
}


Dont'forget to declare the function the list in the delegate header file .h
Let me know if this is not enough for you.


Best Regards
--
Lorenzo
email: email@hidden

> From: "Stephen M. Sebeny" <email@hidden>
> Date: Sat, 02 Aug 2003 14:55:44 -0400
> To: email@hidden
> Subject: NSTableView
>
> Hi,
>
> I saw your recent message on the Cocoa mailing list:
>
>> Hi,
>> I can sort very well an NSTableView clicking on the single header on each
>> column. The problem is that I would like the column header I clicked,
>> remains blue and shows a little black triangle indicating the sort order
>> (ascendent or descendent) like the Finder list windows.
>> Instead the column header after I release the mouse becomes white again,
>> and... no triangle.
>
>
> I am a student writing my first Cocoa app. I am just trying to figure
> out how to sort a table at all. I don't care about the triangle like in the
> Finder. I just want to be able to click the column header and sort. How does
> one go about accomplishing this? If you could give me any pointers, I would
> greatly appreciate it. Thanks!
>
> -----
> Stephen M. Sebeny
> email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: NSButton's setGradientType method
  • Next by Date: Re: Screen Resolution
  • Previous by thread: Re: dock menu
  • Next by thread: e: OT: A proposal, Cocoa in Philly
  • Index(es):
    • Date
    • Thread