简体   繁体   English

如何在Samsung Smart TV应用程序中添加文本输入?

[英]How do I add a text input to a Samsung Smart TV app?

I'm trying to add a text box to an app for Samsung Smart TV. 我正在尝试为三星智能电视的应用添加文本框。 I'm following Samsungs dev guidelines but the following fails because IMEShell is undefined. 我遵循Samsungs dev准则,但由于IMEShell未定义,因此失败。

new IMEShell(this._INPUT_ID, this._imeReady.bind(this), "en");

I have the following in the index.html file: 我在index.html文件中有以下内容:

<script type="text/javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
<script type="text/javascript" src="$MANAGER_WIDGET/Common/API/Widget.js"></script>

What script file do I need to include to get access to IMEShell ? 我需要包含哪些脚本文件才能访问IMEShell

Ok, so it turns out there are two ways of using input in the Smart TV app depending on which type of project you are using. 好的,事实证明,根据您使用的项目类型,有两种方法可以在智能电视应用中使用输入。 If you are creating an AppFramework project you need to have ime listed as a module in the app.json at the root of the project: 如果要创建AppFramework项目,则需要将ime列为项目根目录中app.json中的模块:

{
    "theme" : "base",
    "languages" : ["en"],
    "resolutions": ["540p", "720p", "1080p"],
    "modules" : ["ime"]
}

Then you need to include the AppFramework script in the index.html of your project: 然后,您需要在项目的index.html中包含AppFramework脚本:

<script type="text/javascript" src="$MANAGER_WIDGET/Common/af/2.0.0/loader.js"></script>

Alternatively you can create a javascript project which doesn't use the AppFramewrok code and doesn't require that the project be split into 'scenes'. 或者,您可以创建一个不使用AppFramewrok代码的javascript项目 ,并且不要求将项目拆分为“场景”。 In this case there are a large number of scripts that need to be included: 在这种情况下,需要包含大量脚本:

  <!-- Common API -->
  <!--  Taken from http://www.samsungdforum.com/SamsungDForum/ForumView/df3455b529adf7c4?forumID=8c1afcc0709c2097 -->
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/OpenSrc/jquery-1.4.2.min.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/API/Widget.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/API/Plugin.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/Util/Include.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/Util/Language.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/Plugin/Define.js"></script>
  <script type="text/javascript" src="$MANAGER_WIDGET/Common/IME/ime2.js"></script>

This will create a numeric keypad; 这将创建一个数字键盘; to create a QWERTY keyboard add the following script within the body tag. 要创建QWERTY键盘,请在body标签中添加以下脚本。

  <script type="text/javascript" src="$MANAGER_WIDGET/Common/IME_XT9/ime.js"></script>

There is an example of this on the Samsung Forum . 三星论坛有一个例子。

Once the scripts have been included by one of these methods the rest of the input control docs should work. 一旦这些方法之一包含了脚本,其余的输入控件文档就可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM