Results 1 to 5 of 5

Thread: [RESOLVED] Media Center Remote/Arrow Navigation

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    10

    Resolved [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?)


    Thanks in Advance.
    Last edited by watk6412; Jul 10th, 2009 at 03:37 PM.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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?

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    10

    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.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    10

    Re: [RESOLVED] Media Center Remote/Arrow Navigation

    Thank you. That works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width