Kyle,

>> 1)  to get the field editor to show I have to single click the text field
>> and wait about 1s.  
> 
> Do you have a double-click action specified for the table view? If so,
> NSTableView needs to wait to determine whether to send the click to the
> hit view.

Nope.

> 
>> 2) The field editor only shows if I click on a part of the text field
>> where this is text already, but if I click to the right of the current
>> text (but still within the text field) nothing happens. 
> 
> Are your text view's constraints/autoresizing mask set up correctly to
> stretch with the cell view?

I'm still using the old struts method and I think this is all set up correctly.

> 
>> 3) Double-clicking directly in the textfield does nothing.
> 
> This might be related to the aforementioned double-click behavior.
> 
>> 4) If the row is not selected, and I single click in the textfield, the
>> row is selected, but the field editor is not shown
> 
> This is standard behavior for table views.

In the end I solved this by subclassing the table view, then override mouseDown 
and hit test the text fields to see if one was clicked on. The result works 
really well, though it does require/assume knowledge of the view hierarchy, 
which I don't like so much. But for a fixed internal UI element, it's fine.

The code snippet is below in case it helps anyone else with this problem.

Cheers,

Martin

// we need to override this to restore sensible behaviour of clicking on text 
fields.
- (void)mouseDown:(NSEvent *)theEvent
{
  [super mouseDown:theEvent];
  
  // Get the row on which the user clicked
  NSPoint localPoint = [self convertPoint:theEvent.locationInWindow 
fromView:nil];
  NSInteger row = [self rowAtPoint:localPoint];
  
  // If the user didn't click on a row, we're done
  if (row < 0) {
    return;
  }
  
  // Get the view clicked on
  NSTableCellView *view = [self viewAtColumn:0 row:row makeIfNecessary:NO];
  
  // get container view, which should be the only subview
  view = [view subviews][0];
  
  if (view) {
    // get subview at this location
    NSPoint point = [view convertPoint:[theEvent locationInWindow] 
fromView:nil];
    NSView *v = [view hitTest:point];    
    if ([v isKindOfClass:[NSTextField class]]) {
      NSTextField *tf = (NSTextField*)v;
      if (tf.isEditable) {
        [[view window] makeFirstResponder:tf];
      }
    }
  }
}


> 
> --Kyle Sluder



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to