简体   繁体   English

三星智能电视IME无法聚焦

[英]Samsung smart TV IME not focusing

When I tried to run my code, the whole screen was blur and when I pressed UP/DOWN key, the console showed IME input key skip and call event.preventDefault(), event.stopPropagation() . 当我尝试运行代码时,整个屏幕模糊不清,当我按UP / DOWN键时,控制台显示IME input key skip and call event.preventDefault(), event.stopPropagation()

Part of my codes: 我的部分代码:

HTML: HTML:

<body onLoad="func_onLoad()" onunload="func_onUnload()">
    <input id="username" type="text" onkeydown="onkeydown_input(this)" class="input username" placeholder="Username" required/>
    <input id="password" type="password" onkeydown="onkeydown_input(this)" class="input password" placeholder="Password" required/>
</body> 

ime.js: ime.js:

var username = null;
var password = null;
var currentIMEObj = null;

function func_onLoad(){
alert("func_onLoad begin...");

username = new IMEShell_Common();
username.inputboxID = "username";
username.inputTitle = "username";
username.inputDescription = "Please enter your username";
username.onKeyPressFunc = onKeyCallback_username;
username.context = this;
username.setBlockSpace(true);

password = new IMEShell_Common();
password.inputboxID = "password";
password.inputTitle = "password";
password.inputDescription = "Please enter your password";
password.onKeyPressFunc = onKeyCallback_password;
password.context = this;
password.setBlockSpace(true);

document.getElementById("username").focus();
username.onShow();
}


function func_onUnload() {
alert("func_onUnload begin...");
if(username)
    username.onClose();
if(password)
    password.onClose();
}

function onkeydown_input(obj){
alert("onkeydown_input");
var EKC = event.keyCode;

switch(EKC){
    case(29460)://Up key
        if(obj.id == "username"){
            document.getElementById("username").blur();
            username.onClose();
        }
        else if(obj.id == "password"){
            document.getElementById("username").focus();
            username.onShow();
            currentIMEObj = username;
        }
    break;

    case(29461)://Down key
        if(obj.id == "username"){
            document.getElementById("password").focus();
            password.onShow();  
            currentIMEObj = password;
        }
        else if(obj.id == "password"){
            document.getElementById("password").blur();
            password.onClose();
        }
    break;

    case(29443)://Enter key
        if(obj.id == "username"){
            username.onShow();
            currentIMEObj = username;
        }
        else if(obj.id == "password"){
            password.onShow();
            currentIMEObj = password;
        }
    break;

    case(88)://return
    break;

    case(45)://exit   
        return;
    break;
}
}

function onKeyCallback_username(key,str,id) {
alert("CALLBACK onKeyCallback ===================: " + key + " ID = " + id + " STR = " + str);
switch (key) {
    case (29443): // Enter Key
        alert("ENTER");
        break;
    case (88):  //return
        alert("RETURN");
        break;
    case (45):  //exit
        alert("EXIT");
        break;
}
}


function onKeyCallback_password(key,str,id) {
alert("CALLBACK onKeyCallback ===================: " + key + " ID = " + id + " STR = " + str);
switch (key) {
    case (29443): // Enter Key
        alert("ENTER");
        break;
    case (88):  //return
        alert("RETURN");
        break;
    case (45):  //exit
        alert("EXIT");
        break;
}
}

Any one has any idea why username was not focused even though there was document.getElementById("username").focus(); 任何人都知道为什么即使有document.getElementById("username").focus();也不关注document.getElementById("username").focus(); in the func_onLoad() method and why event.preventDefault() was called. 在func_onLoad()方法中,以及为什么调用event.preventDefault()

Any help is appreciated!!! 任何帮助表示赞赏!!! Thanks in advance!!! 提前致谢!!!

Yes, we had similar problem in development. 是的,我们在开发中也遇到了类似的问题。 The issue arises if you handle the focus in the app independently. 如果您独立处理应用程序中的焦点,则会出现问题。 So if your app uses an independent framework to handle switching focus and active state, IME will not work as it will conflict with your own app's focus. 因此,如果您的应用程序使用独立的框架来处理切换焦点和活动状态,则IME将无法工作,因为它将与您自己的应用程序的焦点冲突。 The only solution is to create your own IME. 唯一的解决方案是创建自己的IME。

I don't no why the problem arises, but i think that andrea-f's answer is not quite right. 我不明白为什么会出现问题,但我认为安德里亚-f的答案不太正确。 Your code is OK. 您的代码正常。 I know that because I had the same problem. 我知道,因为我有同样的问题。 I think that the problem is in the Emulator. 我认为问题出在模拟器上。

I have written very very similar code like yours, and i have had the same problem as yours (the same errors, the dimmed screen, etc.), but when i test the app on real device (my Samsung Smart F6400) it was working perfectly. 我已经编写了与您非常相似的代码,并且遇到了与您相同的问题(相同的错误,屏幕变暗等),但是当我在真实设备(我的Samsung Smart F6400)上测试该应用程序时完美。

Try your app on a real device. 在真实设备上尝试您的应用。 That's my advice to you. 那是我对你的建议。

Good luck! 祝好运!

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

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