KeyHandlers within a scroller

A place for App developers to hang out / post
Post Reply
brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

KeyHandlers within a scroller

#1

Post by brianlich » Mon Nov 25, 2013 5:32 am

I'm having awesome luck on here so I'll try another question. Thanks again for all of the help!

I'd like to hook up the Page Up and Page Down keys in a scroller with a repeater.

I have this markup in my scroll control UI, and not on the MCML page that's calling it (if that makes a difference). The arrow keys work but the page up and page down keys do not. Any ideas?

Code: Select all

<Locals>
      <ScrollingHandler Name="ScrollingHandler" HandleDirectionalKeys="true" HandlePageKeys="true" HandlePageCommands="true"/>
      <ScrollingData Name="ScrollingData"/>

      <KeyHandler Name="PageUpHandler" Key="PageUp" />
      <KeyHandler Name="PageDownHandler" Key="PageDown" />
</Locals>

Code: Select all

<Rules>
      <Changed Source="[PageUpHandler.Invoked]">
        <Actions>
          <Invoke Target="[ScrollingData.PageUp]"/>
        </Actions>
      </Changed>

      <Changed Source="[PageDownHandler.Invoked]">
        <Actions>
          <Invoke Target="[ScrollingData.PageDown]"/>
        </Actions>
      </Changed>
</Rules>

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#2

Post by sccrgoalie1 » Mon Nov 25, 2013 2:42 pm

Did you give the repeater to the scrolling data and the scrolling data to the scrolling handler? In your rules section?

eg:

Code: Select all

      <!-- Give ScrollingData to ScrollingHandler. -->
      <Default Target="[ScrollingHandler.ScrollingData]"
               Value="[ScrollingData]"/>

      <!-- Give Repeater to ScrollingData. -->
      <Default Target="[ScrollingData.Repeater]"
               Value="[FavoritesRepeater]"/>

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#3

Post by sccrgoalie1 » Mon Nov 25, 2013 2:44 pm

Also, if you haven't already I suggest you add this animation to your scroller for smoother scrolling

Code: Select all

<Scroller Orientation ="Vertical"
                            MaximumSize="0,400"
                            FadeSize="-30"
                            ScrollingData="[ScrollingData]">
                      <Animations>
                          <Animation Type="Move">

                            <Keyframes>

                              <PositionKeyframe Value="1,1,1" RelativeTo="Current" Time="0"/>

                              <PositionKeyframe Value="1,1,1" RelativeTo="Final" Time="0.5"/>

                            </Keyframes>

                          </Animation>
                        </Animations>
</Scroller>

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#4

Post by brianlich » Mon Nov 25, 2013 3:43 pm

Yep. Everything seems to be working except for the page up and page down keys. Could it be a focus issue? Is there a way I can ensure that the scroller gets the keys?

sccrgoalie1 wrote:Did you give the repeater to the scrolling data and the scrolling data to the scrolling handler? In your rules section?

eg:

Code: Select all

      <!-- Give ScrollingData to ScrollingHandler. -->
      <Default Target="[ScrollingHandler.ScrollingData]"
               Value="[ScrollingData]"/>

      <!-- Give Repeater to ScrollingData. -->
      <Default Target="[ScrollingData.Repeater]"
               Value="[FavoritesRepeater]"/>

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#5

Post by sccrgoalie1 » Mon Nov 25, 2013 3:49 pm

brianlich wrote:Yep. Everything seems to be working except for the page up and page down keys. Could it be a focus issue? Is there a way I can ensure that the scroller gets the keys?

sccrgoalie1 wrote:Did you give the repeater to the scrolling data and the scrolling data to the scrolling handler? In your rules section?

eg:

Code: Select all

      <!-- Give ScrollingData to ScrollingHandler. -->
      <Default Target="[ScrollingHandler.ScrollingData]"
               Value="[ScrollingData]"/>

      <!-- Give Repeater to ScrollingData. -->
      <Default Target="[ScrollingData.Repeater]"
               Value="[FavoritesRepeater]"/>
How about starting by making sure the keys are recognized in general. Add another action to the key press event to show a dialog to make sure the are firing.

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#6

Post by brianlich » Mon Nov 25, 2013 5:20 pm

Good idea. I'll give that a shot tonight. Thanks!
sccrgoalie1 wrote:
brianlich wrote:Yep. Everything seems to be working except for the page up and page down keys. Could it be a focus issue? Is there a way I can ensure that the scroller gets the keys?

sccrgoalie1 wrote:Did you give the repeater to the scrolling data and the scrolling data to the scrolling handler? In your rules section?

eg:

Code: Select all

      <!-- Give ScrollingData to ScrollingHandler. -->
      <Default Target="[ScrollingHandler.ScrollingData]"
               Value="[ScrollingData]"/>

      <!-- Give Repeater to ScrollingData. -->
      <Default Target="[ScrollingData.Repeater]"
               Value="[FavoritesRepeater]"/>
How about starting by making sure the keys are recognized in general. Add another action to the key press event to show a dialog to make sure the are firing.

sccrgoalie1

Posts: 317
Joined: Fri Jul 08, 2011 5:52 pm
Location:

HTPC Specs: Show details

#7

Post by sccrgoalie1 » Mon Nov 25, 2013 6:19 pm

Also, check out this link, it might help too

http://damianblog.com/2008/08/29/mcml-s ... m-in-list/

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#8

Post by brianlich » Tue Nov 26, 2013 5:50 am

Thanks again for the help! I got it going on a vertical scroller by using ShortcutHandler instead of KeyHandler. However, when I put the exact same code in a horizontal scroller, it doesn't work. I changed the page down to pop a dialog box and that works. Are there different keys I should handle for a horizontal scroller? PageUp and PageDown don't really seem intuitive for a something that goes horizontal.

A little more information. I have a horizontal scroller that I'd like to page left and page right. Does the PageUp and PageDown methods of the ScrollingData element move a horizontal scroller left and right?

leewcraft

Posts: 24
Joined: Mon May 06, 2013 1:36 am
Location:

HTPC Specs: Show details

#9

Post by leewcraft » Wed Dec 04, 2013 2:53 am

I've never tried to access the ScrollingData directly. I think when I've used the PageUp and PageDown handlers, I have them call a NavigateIntoIndex to get it to switch the focus to a particular item, then let the scroller move automatically.

brianlich

Posts: 34
Joined: Wed Jun 08, 2011 1:49 am
Location:

HTPC Specs: Show details

#10

Post by brianlich » Wed Dec 04, 2013 3:21 am

Thanks!

Post Reply