discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSComboBoxCell bug


From: Andreas Höschler
Subject: Re: NSComboBoxCell bug
Date: Fri, 5 May 2006 14:08:12 +0200

Hello,

responding to my own question. I did the following modification in NSComboBoxCell.m that seems to fix the problem.

- (void)validateSelection
{
  if (_cell != nil)
    {
     NSLog(@"validateSelection");
     NSText *textObject = nil;
      NSControl *cv = [_cell controlView];

      if ([cv isKindOfClass: [NSControl class]])
        {
           textObject = [(NSControl *)cv currentEditor];
        }

[_cell setStringValue: [_cell _stringValueAtIndex:[_cell indexOfSelectedItem]]];
      // Will update the editor when needed

// FIXME: Because NSCell doesn't behave correctly the line just over has
      // no effect, to correct this fact, the code below is needed.
[textObject setString: [_cell _stringValueAtIndex:[_cell indexOfSelectedItem]]];
            /*
* Dispatch the text notifications and by side effect update the cell * object value with the -textDidChange: method of NSTextField which is
       * the editor delegate
       */
// [(NSTextView *)textObject didChangeText]; // <-- comment this line out; it triggers completion while clicking items in the tableView
      // End of the code to remove

      if  (textObject != nil)
        {
NSRange selectionRange = NSMakeRange(0, [[textObject string] length]);
          [textObject setSelectedRange: selectionRange];
          [textObject scrollRangeToVisible: selectionRange];
        }       

      [cv sendAction: [_cell action] to: [_cell target]];

      _stopped = YES;
    }
}

Regards,

 Andreas


I have just discovered a bug in NSComboBoxCell. Popping up the combo box and selecting an item leads to the following stack trace (when setCompletes: is set to yes):

#0 -[NSComboBoxCell completedString:] (self=0x8956bd0, _cmd=0xfee93360,
substring=0x925f4e0) at NSComboBoxCell.m:1383
#1  0xfeccfbcc in -[NSComboBoxCell textDidChange:] (self=0x8956bd0,
_cmd=0xfee93310, notification=0xfee93360)
    at NSComboBoxCell.m:1827
#2  0xfe515bef in -[NSNotificationCenter _postAndRelease:]
(self=0x80f1c88, _cmd=0xfe6e8120, notification=0x8195ee0)
    at NSNotificationCenter.m:1070
#3  0xfe515e9f in -[NSNotificationCenter
postNotificationName:object:userInfo:] (self=0x80f1c88, _cmd=0xfe6e8128,
name=0xfeec4048,
    object=0x936e208, info=0x0) at NSNotificationCenter.m:1138
#4  0xfe515dbf in -[NSNotificationCenter postNotificationName:object:]
(self=0x80f1c88, _cmd=0xfeec80f8, name=0xfeec4048,
    object=0x936e208) at NSNotificationCenter.m:1118
#5  0xfedc6b7b in -[NSTextView didChangeText] (self=0x936e208,
_cmd=0xfee930b8) at NSTextView.m:2218
#6  0xfeccd1bc in -[GSComboWindow validateSelection] (self=0x920a0e0,
_cmd=0xfee92fd8) at NSComboBoxCell.m:725
#7  0xfecccbb0 in -[GSComboWindow clickItem:] (self=0x920a0e0,
_cmd=0xfee92dc0, sender=0x8f99da0) at NSComboBoxCell.m:603
#8  0xfe5cdd63 in L10 () from
/opt/GNUstep/System/Library/Libraries/libgnustep-base.so.1.11

completedString: should not be called when the user selects an item from the combo table view. It should only be called when the user enters text. Where do we fix that? I am sure I could find a hook somewhere, but if anyone knows this code better and finds the right line earlier...





reply via email to

[Prev in Thread] Current Thread [Next in Thread]