Frameworks/AIUtilities Framework/Source/AITableViewAdditions.m
branchadium-1.5.10.5
changeset 5999 91f7da2a2338
parent 4897 5ea3bd51010d
equal deleted inserted replaced
5998:c1c33c0ba53a 5999:91f7da2a2338
    74 @interface AITableView : NSTableView {}
    74 @interface AITableView : NSTableView {}
    75 @end
    75 @end
    76 
    76 
    77 @implementation AITableView
    77 @implementation AITableView
    78 
    78 
       
    79 
    79 /* 
    80 /* 
    80  * @brief Load
    81  * @brief Load
    81  *
    82  *
    82  * Install ourself to intercept keyDown: calls so we can stick our delete handling in, and menuForEvent: calls so we can ask our delegate
    83  * Install ourself to intercept keyDown: calls so we can stick our delete handling in, and menuForEvent: calls so we can ask our delegate
    83  */
    84  */
   102 	if (pressedChar == NSDeleteFunctionKey || pressedChar == NSBackspaceCharacter || pressedChar == NSDeleteCharacter) { //Delete
   103 	if (pressedChar == NSDeleteFunctionKey || pressedChar == NSBackspaceCharacter || pressedChar == NSDeleteCharacter) { //Delete
   103 		if ([[self delegate] respondsToSelector:@selector(tableViewDeleteSelectedRows:)])
   104 		if ([[self delegate] respondsToSelector:@selector(tableViewDeleteSelectedRows:)])
   104 			[(id <AITableViewDelegate>)[self delegate] tableViewDeleteSelectedRows:self]; //Delete the selection
   105 			[(id <AITableViewDelegate>)[self delegate] tableViewDeleteSelectedRows:self]; //Delete the selection
   105 	} else {
   106 	} else {
   106 		//Pass the key event on to the unswizzled impl
   107 		//Pass the key event on to the unswizzled impl
   107 		method_invoke(self, class_getInstanceMethod([AITableView class], @selector(keyDown:)), theEvent);
   108         static void (*_key_down_method_invoke)(id, Method, NSEvent *) = (void (*)(id, Method, NSEvent *)) method_invoke;
       
   109 		_key_down_method_invoke(self, class_getInstanceMethod([AITableView class], @selector(keyDown:)), theEvent);
   108 	}
   110 	}
   109 }
   111 }
   110 
   112 
   111 //Allow our delegate to specify context menus
   113 //Allow our delegate to specify context menus
   112 - (NSMenu *)menuForEvent:(NSEvent *)theEvent
   114 - (NSMenu *)menuForEvent:(NSEvent *)theEvent
   113 {
   115 {
   114 	if ([[self delegate] respondsToSelector:@selector(tableView:menuForEvent:)])
   116 	if ([[self delegate] respondsToSelector:@selector(tableView:menuForEvent:)])
   115 		return [(id<AITableViewDelegate>)[self delegate] tableView:self menuForEvent:theEvent];
   117 		return [(id<AITableViewDelegate>)[self delegate] tableView:self menuForEvent:theEvent];
   116         
   118     
   117 	return method_invoke(self, class_getInstanceMethod([AITableView class], @selector(menuForEvent:)), theEvent);
   119     static NSMenu * (*_menu_for_event_method_invoke)(id, Method, NSEvent *) = (NSMenu * (*)(id, Method, NSEvent *)) method_invoke;
       
   120 	return _menu_for_event_method_invoke(self, class_getInstanceMethod([AITableView class], @selector(menuForEvent:)), theEvent);
   118 }
   121 }
   119 
   122 
   120 @end
   123 @end