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?
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
[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.
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.