I'm running into an issue where if a focus even is fired of by javascript on the current window's page it steals focus from my addons input. Is there a way to force an input in a panel to stay focused.
$(inputSelector).focusout(function(){
$(inputSelector).focus();
});
$(inputSelector).blur(function(){
$(inputSelector).focus();
});
I have tried the above which seems to work on my test page but not in my panel :(.
According to the docs -> https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/panel Setting focus to false should
Set to false to prevent taking the focus away when the panel is shown. Only turn this off if necessary, to prevent accessibility issue. Optional, default to true.
I have set my panel up as such.
var text_entry = require("sdk/panel").Panel({
width: text_entry_width,
height: text_entry_h,
focus: false, // doesnt seem to work....
contentURL: data.url("entry.html"),
contentScriptFile: [
data.url("jquery-2.1.1.min.js"),
data.url("text.js")
],
contentStyleFile: [
data.url("styles.css")
]
});
It doesn't append that setting it to false works :(.
Any help, guidance or comments would be awesome :) Cheers.
_____________ UPDATE ____________________________________________
There seemed to be some confusion of my bad explaining :( so i have uploaded a video to youtube that will hopefully explain the issue a bit better.
https://www.youtube.com/watch?v=5fhJzpa515Y&feature=youtu.be
Also below find some more code.
Panel Html
<html>
<head></head>
<body>
<div id="resultTableTop" class="resultTable"></div>
<input type="text" id="edit-box"></input>
<div id="resultTableBottom" class="resultTable"></div>
</body>
</html>
Hot Key Code
var showHotKey = Hotkey({
combo: "accel-t",
onPress: function() {
text_entry.show();
}
});
Panel js show listenter
self.port.on("show", function onShow() {
$('input').focus();
console.log('hi');
});
Hopefully this is a bit clearer now :) thanks for the help so far :).
This code focuses panel's input field when it opens:
main.js file:
get-text.js file which is injected into panel: