How to stop system 'boink' sound

I have canvas and want to ‘scroll a picture’ (not really, but that what it look like), when the user presses the left, up, down, and right arrows.

The canvas doesn’t keep the focus, so the keydown events get caught by one or two other controls like list boxes.

In the listbox key down event, I check for these keys, and in response, I set the value of on of two scrollbars
These cause the canvas to redraw.

dim b as boolean = false If Keyboard.AsyncKeyDown(125) then //do something with the down arrow key... if vscroll.value < vscroll.Maximum then vscroll.value = vscroll.value +10 b=true end if If Keyboard.AsyncKeyDown(126) then //do something with the Up arrow key... if vscroll.value > 0 then vscroll.value = vscroll.value -10 b=true end if if b then return true

And although this feels very kludgy, it works.

However, the mac goes BOINK (no other word to describe it) when the key press is executed.
Like WIndows might go Ding

I can’t find any calls to anything like “Beep” in my code.
Can anyone think of what it is that causes the sound to play?

I think you get that sound when you press a key that the control which receives the key can’t handle.

[code]Const UpKey = 30
Const DownKey = 31

Dim retval As Boolean = False

If Asc(key) = DownKey then
//do something with the down arrow key…

retval = True
ElseIf Asc(key) = UpKey then
//do something with the up arrow key…

retval = True
End

Return retval[/code]

Are you sure you return true in all the keydowns ? This is typical of a keydown that the framework cannot handle.

Else?

His code should just be “Return b” at the end instead of that if statement

[quote=148954:@Jeff Tullin]The canvas doesn’t keep the focus, so the keydown events get caught by one or two other controls like list boxes.

[/quote]

This looks like a potential source of boinks (you can set up alert in Preferences from submarine to tink). If you start catching keydown in several places, you must make sure to return true in every place to avoid an alert.

Thanks. That doesn’t fix or change anything but its nice to know theres always another way to write code.

Sounds reasonable. I’ll start tracking them all down and report back

Found a couple of places that were still getting the event.
Wasn’t causing an issue apart from that awful sound.
But refactoring everything through one method enabled me to quickly add one key zooming into the equation too, so happy now.