PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 29, 2022

[FIXED] How to handle tvOS MenuBarTemplate selection?

 September 29, 2022     tvjs, tvml, tvos     No comments   

Issue

I have a basic MenuBarTemplate set up and displaying.

How do I react to a user's Menu selection and load an appropriate content template?


Solution

In the menuItem tag include a template attribute pointing to the template to load and a presentation attribute set to menuBarItemPresenter.

<menuItem template="${this.BASEURL}templates/Explore.xml.js" 
  presentation="menuBarItemPresenter">
    <title>Explore</title>
</menuItem>

You can then use the menu bar's MenuBarDocument feature to associate a document to each menu bar item.

menuBarItemPresenter: function(xml, ele) {
  var feature = ele.parentNode.getFeature("MenuBarDocument");
  if (feature) {
    var currentDoc = feature.getDocument(ele);
    if (!currentDoc) {
      feature.setDocument(xml, ele);
    }
  }

This assumes you're using a Presenter.js file like the one in Apple's "TVML Catalog" sample. The load function specified there is what calls the function specified in the menuItem's presentation attribute.



Answered By - Jeff Bowen
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing