Getting keyboard selection change events in NSTableView

Discussion in 'Mac Programming' started by aliher, Apr 20, 2009.

  1. aliher macrumors newbie

    Joined:
    Mar 25, 2009
    Location:
    UK
    #1
    Hi,

    I have a separate panel displaying properies of selected row in NSTableView (there are quite a number of them so editing right in table doesn't look like a good idea).
    I'm subscribing to notification for selection change and when I receive it, I set the objects to edit for the property editor. This works fine until I start selecting rows using keyboard. In this case I never get any notifications, but I can see that selected row changes as a result of keyboard commands (via debug button which dumps required properties of controls :).
    What would be a right way to get notifications for that kind of selection changes? I can thing of subclassing NSTableView and handling keyboard events. Is there any other more elegant way?

    UPD: NSTableView's and NSOutlineView's delegate provide functionality that supersedes one provided by notification and notifies on keyboard selection changes. I've missed it when reading docs.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    So were you subscribing manually to the notifications instead of using the delegate method that is handled automatically? It seems odd since it should work either way.
     
  3. aliher thread starter macrumors newbie

    Joined:
    Mar 25, 2009
    Location:
    UK
    #3
    Exactly. I first used notifications as already subscribed to other events. Delegate description says something about its method being notified as a result of notification. But the behaviour seems to be different. As soon as I changed method name and set object as delegate it started receiving all notification. Sounds a bit illogical for me, but it works.
     

Share This Page