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.
  • Re: D/Objective-C 64bit Christian Schneider via Digitalmars-d-announce
    • Re: D/Objective-C 64bi... Jacob Carlborg via Digitalmars-d-announce
      • Re: D/Objective-C ... Christian Schneider via Digitalmars-d-announce
        • Re: D/Objectiv... Jacob Carlborg via Digitalmars-d-announce
          • Re: D/Obje... Christian Schneider via Digitalmars-d-announce
            • Re: D... Jacob Carlborg via Digitalmars-d-announce
              • R... John Colvin via Digitalmars-d-announce
                • ... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
                • ... Jacob Carlborg via Digitalmars-d-announce
                • ... Christian Schneider via Digitalmars-d-announce
                • ... Jacob Carlborg via Digitalmars-d-announce
                • ... Christian Schneider via Digitalmars-d-announce
                • ... Christian Schneider via Digitalmars-d-announce
                • ... Michel Fortin via Digitalmars-d-announce
                • ... Christian Schneider via Digitalmars-d-announce
                • ... Jacob Carlborg via Digitalmars-d-announce
                • ... Christian Schneider via Digitalmars-d-announce
                • ... Jacob Carlborg via Digitalmars-d-announce
                • ... Christian Schneider via Digitalmars-d-announce
                • ... Jacob Carlborg via Digitalmars-d-announce

Reply via email to