ContextOutlineView.m
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:1k
源码类别:

OpenGL

开发平台:

Visual C++

  1. #import "ContextOutlineView.h"
  2. @implementation ContextOutlineView
  3. - (NSMenu*)menuForEvent:(NSEvent*)theEvent
  4. {
  5.     int rowIndex = [self rowAtPoint:[self convertPoint:[theEvent locationInWindow] fromView:nil]];
  6.     if (rowIndex >= 0)
  7.     {
  8.         id item;
  9.         [self abortEditing];
  10.         item = [self itemAtRow:rowIndex];
  11.         if (item != nil) {
  12.             id delegate = [self delegate];
  13.             if ([delegate respondsToSelector:@selector(outlineView:shouldSelectItem:)] && [delegate outlineView:self shouldSelectItem:item])
  14.                 [self selectRow:rowIndex byExtendingSelection:NO];
  15.             if ([delegate respondsToSelector:@selector(outlineView:contextMenuForItem:)])
  16.             {
  17.                 SEL sel = @selector(outlineView:contextMenuForItem:);
  18.                 NSInvocation *invoc = [NSInvocation invocationWithMethodSignature:
  19.                     [delegate methodSignatureForSelector: sel]];
  20.                 if (invoc)
  21.                 {
  22.                     NSMenu *result;
  23.                     [invoc setSelector: sel];
  24.                     [invoc setArgument: &self atIndex: 2];
  25.                     [invoc setArgument: &item atIndex: 3];
  26.                     [invoc invokeWithTarget: delegate];
  27.                     [invoc getReturnValue: &result];
  28.                     return result;
  29.                 }
  30.             }
  31.         }
  32.     } else {
  33.         [self deselectAll:self];
  34.         return [self menu];
  35.     }
  36.     return nil;
  37. }
  38. @end