[RESOLVED] Media Center Remote/Arrow Navigation
Hello, I have made a really simple program launcher for my home theater pc that allows me to launch 6 programs, open/close the optical drive and shutdown. I don't have a mouse or a keyboard normally hooked up. I can navigate the buttons with the up and down arrows fine, but only in the tab index order. Is there a way to allow the left/right arrows to focus on the buttons to the side?
Here is a screen shot of my application to hopefully give a better idea of what I'm asking. (eg. Can I hit the right arrow from my first button and focus on the Open button?)
http://i26.tinypic.com/allnjb.jpg
Thanks in Advance.
Re: Media Center Remote/Arrow Navigation
What up and down arrows are you referring to, since you said you don't normally have a keyboard hooked up?
Re: Media Center Remote/Arrow Navigation
The arrows on the remote function the same as the arrows on a keyboard. So if it works on the keyboard it will work on my remote. Sorry for not making that clear.
Re: Media Center Remote/Arrow Navigation
The arrow keys are a weird set of keys because they act differently in some scenarios. One of those scenarios is when a button is focused. This causes arrow keys to act like the tab key (or shift+tab for reverse) and also causes the key events not to fire.
You can still detect when the arrow keys are pressed when a button has focus, you just need to go about it differently.
Add this to your form
Code:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
Select Case keyData
Case Keys.Right
If Me.ActiveControl Is cmdLaunchXBMC Then
'SET FOCUS TO WHATEVER CONTROL YOU WANT
ElseIf Me.ActiveControl Is cmdEjectTray Then
'ETC...
End If
Return True
Case Keys.Left
If Me.ActiveControl Is cmdLaunchXBMC Then
'SET FOCUS TO WHATEVER CONTROL YOU WANT
ElseIf Me.ActiveControl Is cmdEjectTray Then
'ETC...
End If
Return True
Case Else
Return MyBase.ProcessCmdKey(msg, keyData)
End Select
End Function
Basicall I imagine you are only concerned with left and right arrow, since up and down already act how you would expect and want them to. So this code only filters out right and left arrow key presses, and does whatever you code them to do in the situation...
There is probably a slightly more generic approach to this, but since you don't have very many buttons on your form there, this should suite your needs, and not be a real pain to maintain.
Re: [RESOLVED] Media Center Remote/Arrow Navigation
Thank you. That works great.