D/Objective-C 64bit

Christian Schneider via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Nov 3 00:51:04 PST 2014


I have a question regarding selectors. I wanted to set a 
double-click action in the tableview example. Currently i get the 
selector like this:


     objc.runtime.SEL doubleAction = 
cast(objc.runtime.SEL)&AppDelegate.doubleClickAction ;
     demoTableView.setDoubleAction(doubleAction) ;


Is this the recommended/right way to do it?

Then the double-click action looks like this:


     void doubleClickAction(NSObject sender) {

	NSTableView tableView = cast(NSTableView)sender ;

	if (sender is demoTableView) {
	     NSInteger clickedRow = demoTableView.clickedRow() ;
	     Item item = 
cast(Item)_applications.objectAtIndex(clickedRow) ;
	     
NSWorkspace.sharedWorkspace().launchApplication(item.itemDisplayName()) 
;
	}
     }


I would expect to be using an ObjcObject instead of an NSObject 
here, but this does not compile. The signature of the target 
action seems to be irrelevant, it may have no or more parameters. 
I guess this is just ok and the expected behavior. In 
Objective-C, if the action signature does not comply you will get 
warnings or errors.


More information about the Digitalmars-d-announce mailing list