0

Key handler issues

FAQ - This post is taken from a list of the most frequently asked questions during the pre-release of the WDK

I have been trying to get the key handler working from a button with the following code. It never gets called from what I can tell. If I highlight the button I can hit many keys including right/left and numbers and see the doggy.wakeup outputs from the system so I know the keys are going somewhere but my logging does not get called. The onSelect here does work. Can you tell me what I am doing wrong? How would you capture a key that is not the select button?


var menuItem = new KONtx.control.TextButton(
{
id: 'menuItem-' + buttonIndex,
label: button.Title.Text,
events:
{
onKeyDown: function()
{
log('============keycode ='+event.keyCode);
},
onSelect: function()
{
log('============keyselect');
},
},
styles:
{
vOffset: vertical_offset,
height: $showtime.styles.menu.button_grid_row.height,
},
textStyles: $showtime.styles.menu.button_name
});

by
4 Replies
  • QUOTE (Roger U @ Mar 7 2009, 08:47 PM) <{POST_SNAPBACK}>
    FAQ - This post is taken from a list of the most frequently asked questions during the pre-release of the WDK

    I have been trying to get the key handler working from a button with the following code. It never gets called from what I can tell. If I highlight the button I can hit many keys including right/left and numbers and see the doggy.wakeup outputs from the system so I know the keys are going somewhere but my logging does not get called. The onSelect here does work. Can you tell me what I am doing wrong? How would you capture a key that is not the select button?


    var menuItem = new KONtx.control.TextButton(
    {
    id: 'menuItem-' + buttonIndex,
    label: button.Title.Text,
    events:
    {
    onKeyDown: function()
    {
    log('============keycode ='+event.keyCode);
    },
    onSelect: function()
    {
    log('============keyselect');
    },
    },
    styles:
    {
    vOffset: vertical_offset,
    height: $showtime.styles.menu.button_grid_row.height,
    },
    textStyles: $showtime.styles.menu.button_name
    });


    We should not use onKeyDown events. As far as capturing other keys, the only key you have outside of the standard navigation keys (up/down/left/right/OK) is the Back/Return key. We will be expanding the keyhandler at some point, but you should design around this feature in the first phase of the widget. Please let me know the interaction you are trying to accomplish and we can try to help out.

    I don’t think you should use the onKeyDown event when you are using the KONtx framework, onSelect should work:

    var section0 = new KONtx.control.TextButton({
    label: $_('section_0'),
    secure: false,
    styles: {
    height: buttonHeight
    },
    textStyles: buttonTextStyles,
    events: {
    onSelect: function(type, args, obj) {
    KONtx.application.history.changeState({
    callback: function() {
    KONtx.application.getCurrentApp().switchSection('section-0');
    }
    })
    }
    }
    }).appendTo(menuContainer);
    0
  • FAQ - This post is taken from a list of the most frequently asked questions during the pre-release of the WDK

    I want to get notification of Key press events when the user is on the Snippet so that I can watch for number keys.
    Is there a way to do this? I know we can register a function handler for onSelect events, is there a registration for KeyPress events?

    We want to be able to tell the widget to get data from a “Development” server for the purpose of validating all the data and links. Once validated, we would then update the “production” server with the data.

    On other embedded app projects, we’ve used a secret number code entered via the remote, which caused the app to look at the dev server. We were hoping to use a similar mechanism from the snippet page, so that dev data was gathered to populate the side bar. We certainly don’t want this ability to be available to the general user, so any screen we would implement to input a code would have to be hidden from the user and a secret method of accessing the screen would be required.

    Are you talking about adding a 2nd snippet which is accessed via up or down navigation from the 1st snippet (like a favorite), or actually having 2 snippets side by side on the dock? The first one we are familiar with.
    0
  • QUOTE (Roger U @ Mar 7 2009, 08:52 PM) <{POST_SNAPBACK}>
    FAQ - This post is taken from a list of the most frequently asked questions during the pre-release of the WDK

    I want to get notification of Key press events when the user is on the Snippet so that I can watch for number keys.
    Is there a way to do this? I know we can register a function handler for onSelect events, is there a registration for KeyPress events?

    We want to be able to tell the widget to get data from a “Development” server for the purpose of validating all the data and links. Once validated, we would then update the “production” server with the data.

    On other embedded app projects, we’ve used a secret number code entered via the remote, which caused the app to look at the dev server. We were hoping to use a similar mechanism from the snippet page, so that dev data was gathered to populate the side bar. We certainly don’t want this ability to be available to the general user, so any screen we would implement to input a code would have to be hidden from the user and a secret method of accessing the screen would be required.

    Are you talking about adding a 2nd snippet which is accessed via up or down navigation from the 1st snippet (like a favorite), or actually having 2 snippets side by side on the dock? The first one we are familiar with.



    Snippets never have focus and thus never receive any keystrokes. Dock controls this.

    Yes, adding a second snippet that is accessible by navigating up and down.
    I’m assuming that you will have issues with making changes in the console and setting true statements on dev/production settings.
    Given that we do not expose the numeric keys in dock mode, I think the easiest, fastest way is to create a separate snippet to set the widget to access the development server and use the other snippet to launch widget accessing your production environment. For the final production widget, you can remove the dev snippet. Are you guys familiar with creating other snippets associated with your widget?
    0
  • If you find any of this FAQ confusing, please open a new post with your specific question.
    0

Recent Posts

in General - Yahoo! TV Widgets