NSTokenfield: Drag and Drop / Autocompletion

  • hi

    i hope you can give me a tip for my nstokenfield problems:

    the first problem:
    in the autocompletion list of my token filed are first and surname
    listed. for example "Philippe Regenass".
    now i write philippe and press the space bar, the selected row in the
    list are inserted as token but i don't want this, because i have more
    as one philippe in my address book....

    the second problem:
    i have implement drop functions in the nstokenfield. this works only
    when i drag the file to the border of the tokenfield but not when i
    drag the file in tokenfield. i think the problem is the
    nstokentextview subview in the nstokenfield and specific nstokenfield
    drag and drop methodes for draging tokens.

    best,

    philippe
  • On 04.03.2007, at 23:05, Philippe Heinrich Regenass wrote:

    > the second problem:
    > i have implement drop functions in the nstokenfield. this works
    > only when i drag the file to the border of the tokenfield but not
    > when i drag the file in tokenfield. i think the problem is the
    > nstokentextview subview in the nstokenfield and specific
    > nstokenfield drag and drop methodes for draging tokens.

    Phillipe,

    I found a workaround for that. Problem is the NSTokenField having
    firstResponder state. Please see my solution in a subclass of
    NSTokenField:

    - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
    {
    NSResponder *currentFirstResponder = [[self window] firstResponder];

    if( currentFirstResponder &&
           [currentFirstResponder respondsToSelector:@selector( delegate )] &&
           [currentFirstResponder delegate] == self )
    {
      [[self window] makeFirstResponder:[self window]];
    }

    return NSDragOperationAll;
    }

    Cheers,

    Robert

    --
          ---      -  .-.    --        --
              ---    /  \    ----                        tin:b Software
        .-.        /    \  ---  .-.        __o      .-.        (i)
      /  \      /      \    /  \    _`\<,_    /  \  Robert Fischer
      /    \    /        \  /    \  (*)/ (*)  /    `---------------
    /      `---'          `-'      `-----------'
previous month march 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 31  
Go to today