EventHandler to detect key presses and mouse clicks

Mac OSX specific forum
Niffo
Enthusiast
Enthusiast
Posts: 500
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Re: EventHandler to detect key presses and mouse clicks

Post by Niffo »

In this last sample code, when you press a key, Cocoa triggers an audible error beep if no "keyboard gadget" has the focus.
Do you know how to avoid this ?
I have found an equivalent request on the web but how to implement the proposed solution in PB ?

http://stackoverflow.com/questions/1351 ... error-beep
Niffo
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: EventHandler to detect key presses and mouse clicks

Post by Shardik »

Niffo wrote:In this last sample code, when you press a key, Cocoa triggers an audible error beep if no "keyboard gadget" has the focus.
Do you know how to avoid this ?
A solution to this problem is very easy: simply insert the following line behind the definition of the EditorGadget in wilbert's last code example:

Code: Select all

  CocoaMessage(0, WindowID(0), "makeFirstResponder:", GadgetID(0))
Niffo
Enthusiast
Enthusiast
Posts: 500
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Re: EventHandler to detect key presses and mouse clicks

Post by Niffo »

Thank you very much, it works like a charm when there is a gadget on the window !
But do you have a solution if there is no gadget on the window ?
Last edited by Niffo on Tue Jul 08, 2014 3:11 pm, edited 2 times in total.
Niffo
User avatar
glomph
User
User
Posts: 48
Joined: Tue Apr 27, 2010 1:43 am
Location: St. Elsewhere / Germany
Contact:

Re: EventHandler to detect key presses and mouse clicks

Post by glomph »

I really would like to know it too.
Post Reply