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

Thursday, September 29, 2022

[FIXED] How to add detect button presses in tvOS?

 September 29, 2022     apple-tv, swift, tvos     No comments   

Issue

I have follow this tutorial and everything works fine. The only issue I'm having is i can't figure out how to detect when a button has been pressed?

Thanks in advance


Solution

Author of the tutorial here, the method of adding interactivity to TVML-based apps is to use addEventListener on the DOM element in question. You can find the DOM element by holding a reference to it during creation, or by using getElementById or other such similar JavaScript DOM techniques. Also, I should mention I've added a "Part 2" to the mentioned tutorial which includes this as it's primary focus.

Here's an example of how you might do this in JS, assuming myDOMElement is a variable that references your button as a DOM element.

  myDOMElement.addEventListener("select", function() { alert("CLICK!") }, false);

I have more info on the tutorial of course, so feel free to check that out, too.



Answered By - Jameson
Answer Checked By - Cary Denson (PHPFixing Admin)
  • 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