Spotting a control upon page load (aka default control)

Hi! I want to be able to spot a control once page is loaded (or well whenever i want it)
I've tried number of ways:

enyo.Spotlight.setCurrent(this.$.bButton);
enyo.Spotlight.spot(this.$.bButton);
this.$.bButton.focus();

none works. Looked at spotlight samples - nothing. I am missing something obvious, can you please help out :)

Relevant jsfiddle here:

https://jsfiddle.net/sheree_boman/w12kf5k3/13/


To continue on the question - i have a data list that loads items from json data source. I need to be able to spot on the first element of the list once list is loaded. On which event should i be adding the spotting routine? (to make this work i need first to figure out how the first part works :) )

Thanks!

Comments

  • Hi @sheree_boman, to give you some background, Spotlight attempts to make consistent and reasonable choices, and you usually do not need to programmatically make spot calls. By default, Spotlight will attempt to spot the first spottable control, which in your fiddle would be Button A. You have explicit calls to spot - are you needing to spot a control that is not the first control?

    To give you further background, there is support for both pointer (mouse) and 5-way (keyboard) modes. A general rule of Spotlight is that, in pointer mode, only the element focused by the pointer can be spotted, to prevent any disconnect (i.e. the pointer is in the upper left, while a button in the lower right is spotted, would be confusing for the user). In your fiddle, Spotlight is in pointer mode when the sample is run, and thus your programmatic spot calls have no real effect (nor would the default spotting of the first control take effect).

    To illustrate the point, I have made a small tweak to explicitly set the pointer mode to false, before programmatically spotting: https://jsfiddle.net/w12kf5k3/20/. Here is a version without your explicit spot call - notice that Button A is spotted: https://jsfiddle.net/w12kf5k3/19/. Note that this is not really recommended practice, as we are forcefully breaking some of Spotlight's rules. Also, don't forget to call the super method if you're overriding rendered (via this.inherited).

    In the latest Enyo, we have made some updates to better support this scenario, and you can pass an option to the spot call, like so (the general syntax has changed a little bit to support modules, as a heads-up):
    https://jsfiddle.net/aarontam/77c8xm3n/

    Maybe another question for you is whether the default/explicit spotting functioning for 5-way is sufficient for your purposes, and if not, why not?
  • Thanks, that explains a lot.
    Basically when an app on TV starts, i want some default control to be focused.
    Then when user is browsing around the app and pressing buttons i need to be able to help user to navigate if they use standard remote, so checking whether pointer mode is enabled before focusing is a solution. Thanks a lot!!
Sign In or Register to comment.