codeSense

  • I'd like to give a textfield codeSense type capabilities.
    Specifically, display a floating box with guesses that change as the
    user types.  A combobox doesn't work because there can be multiple
    entries in the one textfield: "Robert, Mary", etc. The delegate
    method:
    control:textView:completions:forPartialWordRange:indexOfSelectedItem:, d
    oesn't work because it doesn't display a selection list.

    What I've tried is creating a small window with a tableView in it. I
    use the textFields controlTextDidChange delegate to figure out if I
    need to display the list. As far as it goes this works. The problems
    are (so far):

    1.  When xCode puts up the codeSense selection list, the list accepts
    up/Down arrows and the textView accepts alpha/numeric keystrokes. I
    don't see how to do that. I sub-classed NSTableView to capture the
    keystroke, but then what?

    2.  The tableView doesn't accept the setDoubleAction: method. In
    fact, to get the single click action to work I had to set it in IB.

    Does anyone have suggestions?
  • On Jun 6, 2007, at 7:11 PM, Tony Cate wrote:

    > 1.  When xCode puts up the codeSense selection list, the list
    > accepts up/Down arrows and the textView accepts alpha/numeric
    > keystrokes. I don't see how to do that. I sub-classed NSTableView
    > to capture the keystroke, but then what?

    Try letting the text field handle input and take a look at
    control:textView:doCommandBySelector: instead.  Dealing with raw
    keystrokes is usually troublesome.

    Douglas Davidson
  • I have no idea how it's done, but Colloquy ( http://colloquy.info )
    does something like that. Try looking at their source.

    - Ofri

    - - - - - - - - - - - - - - - - - - -
    http://www.dpompa.com
    - - - - - - - - - - - - - - - - - - -

    On 07/06/2007, at 05:11, Tony Cate wrote:

    > I'd like to give a textfield codeSense type capabilities.
    > Specifically, display a floating box with guesses that change as
    > the user types.  A combobox doesn't work because there can be
    > multiple entries in the one textfield: "Robert, Mary", etc. The
    > delegate method:
    > control:textView:completions:forPartialWordRange:indexOfSelectedItem:,
    > doesn't work because it doesn't display a selection list.
    >
    > What I've tried is creating a small window with a tableView in it.
    > I use the textFields controlTextDidChange delegate to figure out if
    > I need to display the list. As far as it goes this works. The
    > problems are (so far):
    >
    > 1.  When xCode puts up the codeSense selection list, the list
    > accepts up/Down arrows and the textView accepts alpha/numeric
    > keystrokes. I don't see how to do that. I sub-classed NSTableView
    > to capture the keystroke, but then what?
    >
    > 2.  The tableView doesn't accept the setDoubleAction: method. In
    > fact, to get the single click action to work I had to set it in IB.
    >
    > Does anyone have suggestions?
  • On Jun 6, 2007, at 19:18, Douglas Davidson wrote:

    >
    > On Jun 6, 2007, at 7:11 PM, Tony Cate wrote:
    >
    >> 1.  When xCode puts up the codeSense selection list, the list
    >> accepts up/Down arrows and the textView accepts alpha/numeric
    >> keystrokes. I don't see how to do that. I sub-classed NSTableView
    >> to capture the keystroke, but then what?
    >
    > Try letting the text field handle input and take a look at
    > control:textView:doCommandBySelector: instead.  Dealing with raw
    > keystrokes is usually troublesome.

    I'd also look at using the system's completion via
    control:textView:completions:forPartialWordRange:indexOfSelectedItem:,
    possibly displaying it on a timer.  I think Douglas Davidson posted an
    example on this list that might get you started.

    If you want to look at a working implementation (BSD license), we
    implemented it from scratch in BibDesk.  Note that we were subclassing
    the field editor for other reasons, so there's a lot of extraneous
    code here.

    http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKTextVie
    wCompletionController.m?view=log

    http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKFieldEd
    itor.m?view=log

    http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/NSTextView_
    BDSKExtensions.m?view=log


    regards,
    Adam Maxwell
  • Many thanks, for the great replies, to Doug, Adam, and Ofri . I think
    I'm pointed in the right direction now.

    Tony

    On Jun 6, 2007, at 9:18 PM, Douglas Davidson wrote:

    > Try letting the text field handle input and take a look at
    > control:textView:doCommandBySelector: instead.  Dealing with raw
    > keystrokes is usually troublesome.
previous month june 2007 next month
MTWTFSS
        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  
Go to today