Weird Beeping

My project compiles, builds, and runs on both Windows and Mac. I have it setup so when you hold down spacebar you can pan around the document. Works flawless but there is a super weird behavior on Mac when you first launch the app.

The process is that you launch the app, drag in an image and then can hit space bar to pan around. If you do not click on the document first when you hold down space bar I just get a constant “Beep” as if I am in a modal dialog or something. Once you click anywhere inside of the window it stops doing this when you press the space bar.

I have overridden keyStateChanged and keyPressed and it works great.

Anyone have an idea? Even the Demo project beeps if you hit a key. I am assuming the app thinks nobody is listening to some behavior I just can’t find what it is and why it changes once you click.

Is it possible that after launching the application, it hasn’t got the focus yet?
The moment you click the window it requests and receives the focus, so it reacts normally to your key events.

Perhaps you could try experimenting with the following operations on your DocumentWindow or its content component:

  • grabKeyboardFocus()
  • setWantsKeyboardFocus(true)
  • toFront(true)

I tried all of these approaches to no avail. It really is not a huge situation as most of the time you really use the app by clicking on the window but it is something that I would like to figure out and address.

[quote=“vbaeten”]Is it possible that after launching the application, it hasn’t got the focus yet?
The moment you click the window it requests and receives the focus, so it reacts normally to your key events.

Perhaps you could try experimenting with the following operations on your DocumentWindow or its content component:

  • grabKeyboardFocus()
  • setWantsKeyboardFocus(true)
  • toFront(true)[/quote]