CPTGraphHostingView capturing responder chain?

21 views
Skip to first unread message

Demitri Muna

unread,
Mar 3, 2017, 6:57:25 PM3/3/17
to coreplot-discuss
Hi,

I have a window with a split view, on one side containing a CPTGraphHostingView. I have a custom subclass of NSVIewController that manages the view. The hierarchy is like this:

Window -> [ View A | View B ]

A direct subview of View B is a CPTGraphHostingView, and the controller in question manages View B. In the controller I have an IBAction (let's say "copyAThing:") that is implemented in the controller. I have a menu item in the main menu which is set to that action and the first responder as its target. I have this implemented in several view controllers and validateMenuItem: is called in each of these.

In this particular setup, validateMenuItem: is not called. There aren't too many places this can go wrong - I have the firstResponder set as the target, the action is implemented, and I'm running 10.11 so I know the controller should be in the responder chain. Is there maybe something in CPTGraphHostingView or in my graph that might be surpassing call? I tried subclassing View B (normally a plain NSView) to implement validateMenuItem: to see if it will be called there, but it's not. I have acceptsFirstResponder on the controller returning YES (though that shouldn't be needed), and I put a debug point in becomeFirstResponder:, which is never called.

I'm running 10.11 and the latest check out of Core Plot.

Any suggestions welcome!

Cheers,
Demitri

Eric

unread,
Mar 3, 2017, 8:23:58 PM3/3/17
to coreplot-discuss
It's certainly possible that there's a bug in CPTGraphHostingView that interferes with the responder chain. What version of Core Plot are you using?

Does the app work correctly if you temporarily remove the hosting view? If that fixes it, I'll dig deeper into the Core Plot code and fix the problem.

Eric

Demitri Muna

unread,
Mar 3, 2017, 9:04:18 PM3/3/17
to coreplot-discuss
Hi Eric,

I have more information, but not a solution. I removed the CPTGraphHostingView and still had a problem. I created a subclass of the main NSView and implemented one of the menu methods and calidateMenuItem: inside it. When this happened, validateMenuItem: is now called from the view controller. I have a menu in the Edit menu with one item that has submenus. Strangely, only the controller's validate method is called when the menu is selected as it is a target for a top level Edit menu item where the hosting view is not, but when I select the sub-menu (which the subclassed NSView is a target of), both get called. In other words, the presence of the subclassed NSView causes the controller validate method to be called even if it's not called itself.

My master/detail split view has an outline view on the left, the views in question on the right (see screenshots here: https://itunes.apple.com/us/app/nightlight/id1116838680). With the CPTGraphHostingView removed, the validation only works if I click on the empty view, i.e. it has focus. When I put the CPTGraphHostingView back, it won't work, but I see why now. When I click the graph, I see the outline view on the left still has focus, which means the views on the right are not part of the responder chain. I'm guessing the CPTGraphHostingView captures the mouse click I'm performing to try to capture focus.

I still don't understand why I need to subclass the NSView to get validateMenuItem: called when the docs say that view controllers are part of the responder chain starting with 10.10, but it at least works (if there is no CPTGraphHostingView).

The version of Core Plot I'm using is the head of release 2.3.

Thanks,
Demitri

Eric

unread,
Mar 4, 2017, 12:28:12 PM3/4/17
to coreplot-discuss
Does your graph have any delegates that respond to user interaction? The hosting view forwards mouse and trackpad events that aren't handled by the graph to the next responder.

Eric
Reply all
Reply to author
Forward
0 new messages