Baffled getting mouse events

I must be missing something entirely. I cannot figure out how to get a mouse event from a click in my Window. I presumed it would be as easy as

on rightMouseUp_(theEvent)
    log "right mouse up"
-- do some stuff
end rightMouseUp_

…but I’m obviously missing a connection somewhere. Any guidance appreciated, as always.

Where are you putting the handler?

The handler is in the single appDelegate script of the AppDelegate.applescript, alongside awakeFromNib_, applicationWillFinishLaunching_, and so on.

There’s a bit more to it than that; the event gets sent to the relevant view, so you need the handler on the view.

This means subclassing NSView: make a new subclass (File → Insert File, choose subclass of NSView), then selecting the content view in IB and changing its class to the new class you just made (in the Identity panel of the Inspector). Then you can add the handler to your class.

If you don’t want to use the existing content view of a window, you can add a custom view and follow the same steps.

Ah ha! I knew I was missing something. Of course, that works just fine. Thanks for the help. Really.