CPTableColumn Header Menu

44 views
Skip to first unread message

david.ri...@enquora.com

unread,
Jul 6, 2016, 12:21:16 PM7/6/16
to Cappuccino & Objective-J
We have tableview columns that need menus (for sort, filtering and copying/fill options).
I've found no useful examples in objective-j or objective-c but it looks necessary to subclass CPTableHeaderView and provide a custom delegate. 

The mouse click delegate method for headers doesn't expose the specific column clicked and it would be necessary to manually position and manage a menu at the cursor co-ordinates.

Providing the menu on a simple mouse click feels most natural to me, but these columns are also draggable and I suspect some users would assume dragging isn't possible if they are immediately presented with a menu on clicking. A right-click menu seems to avoid this.

I would like to implement this functionality either in IB or code - which again suggests a subclass with custom delegate.
Does anyone have experience with this situation? Thoughts?

Am I missing anything that doesn't require subclassing?


Martin Carlberg

unread,
Jul 7, 2016, 8:19:36 AM7/7/16
to objec...@googlegroups.com
Hi David,

There is a ’mouseDownInHeaderOfTableColumn:’ delegate method that you might use. You will get which column header that is clicked. If that is not sufficient I guess you have to subclass the table view header view itself.

I also think that providing the menu on a simple click feel most natural but you might need to test this in real life to get a feeling if it will work. You could maybe open the menu on mouse up or after a small delay (with no mouse movement) on mouse down.


- Martin


--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

david.ri...@enquora.com

unread,
Jul 7, 2016, 5:20:34 PM7/7/16
to Cappuccino & Objective-J

There is a ’mouseDownInHeaderOfTableColumn:’ delegate method that you might use. You will get which column header that is clicked. If that is not sufficient I guess you have to subclass the table view header view itself.
 
Thanks Martin - I completely overlooked that somehow. What is the best way to locate the mouse position so the menu can be launched with origin matching the normal offset as used by a context-menu? Add a tracking area using the headerView's frame rectangle?

 

david.ri...@enquora.com

unread,
Jul 7, 2016, 5:52:44 PM7/7/16
to Cappuccino & Objective-J


On Thursday, July 7, 2016 at 6:19:36 AM UTC-6, mrcarlberg wrote:
I also think that providing the menu on a simple click feel most natural but you might need to test this in real life to get a feeling if it will work. You could maybe open the menu on mouse up or after a small delay (with no mouse movement) on mouse down.

I will try adding a Help/Instructional view as the first item in the menu. I'd like to dismiss the menu immediately if a drag operation begins.
I expected to see a delegate method for the start of the drag operation but I don't see anything that will help.
Looks as though it will require some effort to create a polished effect. 

david.ri...@enquora.com

unread,
Mar 10, 2017, 12:49:58 PM3/10/17
to Cappuccino & Objective-J
The correct way to implement this is by adding a menu to the headerView of a tableColumn. 
It isn't now clear to me what the usage case is for a menu attached to CPTableHeaderView, but this isn't it.
Reply all
Reply to author
Forward
0 new messages