Firefox(Android版)の拡張機能を作ろうとしています
ユーザーが長押ししたときにテキストを選択する必要があります。
私はそのようなコードを持っています:
.....
Services.obs.addObserver(this, "Gesture:LongPress", false);
.....
observe: function(aSubject, aTopic, aData) {
if (aTopic == "Gesture:LongPress") {
var xw = this._xulWindow;
var document = xw.BrowserApp.selectedBrowser.contentDocument;
var selectedText = document.getSelection().toString();
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
prompts.alert(null, "ColorDict", selectedText);
}
}
....
しかし、私は空のアラートを受け取ります。LongPressハンドラーが終了した後に単語が選択されるためです。ユーザーが長押しした後、どのようにして選択された単語を取得できますか?