Tuesday, December 12, 2017

#1 2009-10-28 08:48:32 pm

DougAdams
Member
From:: Newton, MA, USA
Registered: 2003-05-09
Posts: 81
Website

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

Applescript:

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.


Doug

Offline

 

#2 2009-10-28 09:53:47 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Baffled getting mouse events

Where are you putting the handler?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2009-10-29 06:19:05 am

DougAdams
Member
From:: Newton, MA, USA
Registered: 2003-05-09
Posts: 81
Website

Re: Baffled getting mouse events

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


Doug

Offline

 

#4 2009-10-29 08:14:52 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Baffled getting mouse events

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2009-10-29 08:28:05 am

DougAdams
Member
From:: Newton, MA, USA
Registered: 2003-05-09
Posts: 81
Website

Re: Baffled getting mouse events

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


Doug

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)