キーボード ショートカットで (roundcube 内の) 特別な ID にフォーカスしたい。htmlは
...
<div id="mainscreen">
<div id="messagetoolbar" class="toolbar">
<div id="mailview-left" style="width: 220px;">
<div id="mailview-right" style="left: 232px;">
...
私は次のことを試しました:
// Strg + Tab, um in Nachrichtenbereich zu kommen
...
else if (event.keyCode == 9 && event.ctrlKey) {
alert("taste erkannt");
//document.getElementById("messagetoolbar").focus();
//$("#messagetoolbar").focus();
setTimeout(function() { $('#messagetoolbar').focus(); alert("zeit"); }, 3000);
}
...
最初のアラートと 2 番目のアラートが表示されますが、id messagetoolbar にはフォーカスがありません。誰かアイデアがありますか?
どうもありがとうございました。
編集:もっとよく説明する必要があると思います: roundcube のメール受信ボックスの最初の行/メールにマークを付けたいです。受信トレイはtrタグ付きのテーブルです...解決策を試すと、最初の行にも点線が表示されますが、Enterキーではメールを開くことができず、他のキーでは最初の行/メールをマークできません...最初の行をマークするには、「左クリックをシミュレート」する必要があると思います...?
今、jquery の .trigger を使用しようとしました。inbox-Table の html は
<table id="messagelist" class="records-table messagelist sortheader fixedheader">
<thead>
<tbody>
<tr id="rcmrow27428" class="message">
<td class="threads"></td>
<td class="date">16.04.2014 13:41</td>
<td class="fromto">
...
使ってみた...
$('#messagelist tr').eq(1).addClass('message selected focused').removeClass('unfocused').trigger("click");
...しかし、機能しません:クラスを追加および削除しますが、実際には行に焦点を合わせていません:-(「ボタン」を使用すると機能します。
もう一度編集: roundcube のファイル list.js はその質問にとって重要だと思います。そこで私は次のことを見つけました。
/**
* Set focus to the list
*/
focus: function(e)
{
var n, id;
this.focused = true;
for (n in this.selection) {
id = this.selection[n];
if (this.rows[id] && this.rows[id].obj) {
$(this.rows[id].obj).addClass('selected').removeClass('unfocused');
}
}
// Un-focus already focused elements (#1487123, #1487316, #1488600, #1488620)
// It looks that window.focus() does the job for all browsers, but not Firefox (#1489058)
$('iframe,:focus:not(body)').blur();
window.focus();
if (e || (e = window.event))
rcube_event.cancel(e);
},
私の質問を参照して変更または使用する方法を知っている人はいますか? ありがとうございました!