0

I have a NSSplitViewController and in one of the items I have multiple buttons with keyboard shortcuts.

Once the user hides the item, the shortcuts don't fire. Is there any way to keep the buttons in the hidden view as part of the responder chain?

mangerlahn
  • 4,746
  • 2
  • 26
  • 50

1 Answers1

1

Sounds like the simple answer is no, according to Apple's docs. A simple workaround, however, might be to move the buttons out of the visible area by, say, shifting their bounds right by 10,000 or so. If they are in a scrollview/clipview that would expand to show the items in their new position, then this would not work so well, but if they aren't, it ought to work fine. If they are in a scrollview, then you might find a way to make them completely transparent, to achieve a similar effect.

That said, perhaps it is worth considering whether you have the right design in the first place, since having buttons that are not visible respond to key events is a questionable design from a user-interface perspective (as reflected by the fact that Apple tries to prevent it). Maybe those keyboard events should really be getting handled by a view higher in the view hierarchy, or by the window, or some such entity?

bhaller
  • 1,803
  • 15
  • 24
  • Thank you for your answer! I already do it that way (transparent somewhere in the window background) but this is simply a hack. Furthermore I agree that buttons should be visible in order to use them. – mangerlahn Oct 11 '15 at 20:11
  • But in my special case (a calculator), most users are going to use the physical keyboard anyway, thats why I wanted to give them the possibility to reduce the apps visible space. – mangerlahn Oct 11 '15 at 20:12
  • Makes sense. Seems like the hack is necessary. – bhaller Oct 12 '15 at 01:48