私はキープレスデリゲートイベントを追加しましたが、イベントでは座標を取得できません。Aureliaでキー入力イベントに基づいてテキストエリア内のカーソルの座標を取得する方法は?
カーソルの位置にauto-suggestのリストを表示するには、topプロパティとleftプロパティのCSSを変更する必要があります。 .TSファイルで
<div class="dropdown suggest open" data-key="." css="display: ${autoSuggestTool.display}">
<ul class="dropdown-menu" role="menu" css="top:${autoSuggestTool.top}; left: ${autoSuggestTool.left};">
<li data-value="Test" class="active "><a href="#"><small>Test</small></a></li> </ul>
</div>
<textarea class="form-control" rows="5" cols="6" id="comment" value.bind="textAreaValue" keypress.delegate="autoSuggest($event)" placeholder="Type text "></textarea>
//コード:
autosuggest(event){
//here i need the pageX and PageY or offset to set the postion
//this.autoSuggestTool.left = event.pageX;
//this.autoSuggestTool.top= event.pageY;
//**But in event i am not getting the co-ordinate of cursor inside textarea**
//How to get the co-ordinate of cursor on key press in aurelia.
}
ありがとうございます。しかしキーフィールドに基づいてテキストエリア内の座標を取得するための他の方法がAureliaにあります。これらの座標を使用して、入力されたキーに基づいて自動提案リストの位置を設定することができます。 –
私は上記のevent.target.getBoundingClientRect()を試しましたが、キーが押されたテキストエリア内のカーソル位置ポイントではなく、テキストエリアの座標のみを返します。 –