• 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 row counter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView row counter


  • Subject: Re: NSTableView row counter
  • From: Ryan Bates <email@hidden>
  • Date: Sun, 15 Feb 2004 13:55:19 -0800

You can get the position of the vertical scroll bar like this (in Obj-C):

scrollPosition = [[[tableView enclosingScrollView] verticalScroller] floatValue];

Another idea is to get the table's visible rect (the portion of the table view visible on the screen). This might help determine what rows to draw:

visibleRect = [tableView visibleRect];

The best thing to do is play around with it and see what works best. It might not be a bad idea to put this NSView subclass in its own NSClipView or NSScrollView and hide the scrollers - that way you only have to concentrate on syncing the scrolling.

Ryan

On Feb 15, 2004, at 9:23 AM, Moray Taylor wrote:

This sounds good, I had a quick go, but didn't get very far, I have an outlet to the TableView, and it's already subclassed for other reasons, so this method would fit well.

How would I draw the row counter in the NSView, I suppose I would need to get the position of the scrollbar or something?

The reason I wanted to use an NSRulerView is that it *almost* does exactly what I need, the synchronized scrolling is already taken care of.

If anyone has any examples of this type of thing, I'd love to see it. The program I am writing is Cocoa/Java, but Obj-C code is just as welcome.

Thanks

Moray

How about simply putting an NSView subclass next to an NSTableView? If you have an outlet to the table view you could get information (such as the row height). The problem is you don't know when to redraw this view. One way would be to subclass NSTableView as well and tell the NSView subclass to redraw every time the table is redrawn.

This way is very hack-ish, but it should work. If you are developing a framework that other programmers will use you will want to think of something better. The right way to do this would be to subclass NSTableView and implement the row headers similar to the column headers, but I think you would need to know more about NSTableView than the documents provide in order to accomplish this.

Ryan


On Feb 15, 2004, at 6:00 AM, Moray Taylor wrote:

Hi,

I am currently investigating ways to put a row counter onto my NSTableView, like a spreadsheet. I can't just use the first column, as it disappears when I scroll horizontally.

I was thinking of using a NSRulerView, as it does everything I need it to do, apart from the numbers are in the wrong places, and just don't look the way I want them to. Should I overide the drawRect:, or am I barking up the wrong tree?

The line counter in XCode's text editor is almost what I want, how is that done?

Thanks v much

Moray
_______________________________________________
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.
_______________________________________________
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.
_______________________________________________
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.

References: 
 >NSTableView row counter (From: Moray Taylor <email@hidden>)
 >Re: NSTableView row counter (From: Ryan Bates <email@hidden>)
 >Re: NSTableView row counter (From: Moray Taylor <email@hidden>)

  • Prev by Date: Re: ANN: Doxygen for MacOS X with Objective-C support
  • Next by Date: Re: ANN: Doxygen for MacOS X with Objective-C support
  • Previous by thread: Re: NSTableView row counter
  • Next by thread: [NSString UTF8String] performance
  • Index(es):
    • Date
    • Thread