이 tv.ui.button은 처음로드 될 때 마우스 커서로만 응답하지만 한 번 이상 클릭 한 후 키보드 ENTER 또는 마우스 클릭에 응답합니다. 내가 여기서 뭔가 잘못 됐니?tv.ui.button 페이지로드시에만 마우스 스틱에 응답
HTML
<div class="tv-button alert-button" id="test-button">Alert button</div>
JS
decorateHandler.addClassHandler('alert-button', function(button) {
goog.events.listen(button, tv.ui.Button.EventType.ACTION,
function() {
alert('Button clicked.');
var elementToFocus = goog.dom.getElement('tab1');
var componentToFocus = tv.ui.getComponentByElement(elementToFocus);
tv.ui.Document.getInstance().setFocusedComponent(componentToFocus);;
});
});
편집 : 그것은이 특별히 자바 스크립트에 대한 질문이 아니라 폐쇄 될 수있다 보인다. 적절한 태그 아래에 새로운 질문을 게시하고 있습니다.
잘 모르겠다. 커서 포커스는 어떻게 정의됩니까? – ejfrancis
이 StackOverflow 답변을보십시오 : http://stackoverflow.com/questions/148361/how-can-i-give-keyboard-focus-to-a-div-and-attach-keyboard-event-handlers-to -it – Krispy
tabindex = 0처럼 추가했습니다.