Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7720057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:34:08+00:00 2026-06-01T03:34:08+00:00

I am using the Add-on Builder to create an icon in the addon toolbar

  • 0

I am using the Add-on Builder to create an icon in the addon toolbar which opens a panel.

var panel = require("panel").Panel({
    contentURL: data.url("panel.html"),
    contentScriptFile: [
        data.url("panel.js"),
    ]
});

var widget = new Widget({
    id: "player",
    label: "Player",
    contentURL: data.url('icon.png'),
    panel: panel,
});

I want the panel to get the focus as soon as I click the icon. The following code to send a keyup event to the addon just works if I have activated the panel before with a mouse click.

$(document).keyup(function(event) {
   event = event || window.event;
   self.port.emit('keyup', event.keyCode);
   return false;
});

Is there a way to focus the panel and report key presses instantly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:34:10+00:00Added an answer on June 1, 2026 at 3:34 am

    I think the issue is that you need to run code in your content script when the panel is opened, not when the document is loaded. To do this you need to emit an event into the content script when the panel event ‘show’ is emitted on the panel object. Here’s an example of how this would work:

    main.js:

    var data = require("self").data;
    
    var panel = require("panel").Panel({
        contentURL: data.url('panel.html'),
        contentScriptFile: [data.url('jquery.js'), data.url('panel.js')]
    });
    
    panel.on('show', function() {
        console.log('main: opened panel')
        panel.port.emit('opened', true);
    });
    
    panel.port.on('keyup', function(keyCode) {
        console.log(keyCode);
    });
    
    require("widget").Widget({
        id: 'my-widget',
        contentURL: data.url('favicon.ico'),
        label: 'Click for panel...',
        panel: panel
    });
    

    panel.js:

    $(function() {
    
        $(document).keyup(function(event) {
           event = event || window.event;
           self.port.emit('keyup', event.keyCode);
           return false;
        });
    
    
        self.port.on('opened', function(data) {
            console.log('panel: opened panel')
            $('#my-input').focus();
        });
    });
    

    Here’s a working example in Builder:

    https://builder.addons.mozilla.org/addon/1047238/latest/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Add-on builder and I need to receive binary data (image).
I have created an add-on using firefox's add-on builder. I am able to create
I'm using the Firefox Add-on Builder and here is what I have so far:
I have GUI created using netbeans GUI builder. I want to add there an
I am using Qt Builder to create a simple window. I used the menu
I'm attempting to create a class with many parameters, using a Builder pattern rather
I am using C++ Builder to create a VCL form application. Right now I
Using Flash Builder 4 (with 4.1 flex). Trying to create a state change after
I am trying to insert a div inside another div using add() of jquery
I have a .net winforms ListBox and I've added items to it using .Add().

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.