Which element was selected in completion pull-down?

  • Hello list.

    I'm now getting the expected completion behavior for my Safari-style
    address field (thanks to Stephen Butler's advice), but now I need to
    determine which element (if any) in the completion pull-down was
    selected when the field's action is sent.

    The completion pull-down is an NSWindow with a table view that uses
    an undocumented table model class according to F-Script. The
    completion pull-down window appears to a child window of the window
    that contains the address field.

    The field's action is sent on enter, so I'd like to be able to
    determine at that time which object (if any) was selected in the
    completion pull-down. I can think of a couple approaches, but am not
    sure how to implement either one. Here are the two alternatives I can
    think of:

    * Provide the objects to the pull-down and provide a formatter to
    select the proper string for display in the menu. If this is a good
    approach, how do I provide the formatter to the pull-down model? I
    don't know how to get a reference to the pull-down during completion.
    How do I determine which item was selected? Is it the object of some
    notification I can get?

    * Remember the result of the query that populates the pull-down. When
    the action is invoked on enter, get the index of the selected item
    (if any), then grab the object at the same index. In this case, I
    don't know how to get the index of the selected item, or how to get a
    reference to the pull-down in order to establish a listener. Does the
    pull-down post notifications?

    I have checked the docs for NSTextView, NSControl and their
    respective superclasses for hints, and can't see any obvious delegate
    methods or mention of notifications.

    Any advice is most welcome. Thanks.
previous month october 2007 next month
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today