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 8623437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:16:50+00:00 2026-06-12T07:16:50+00:00

I want only one folder choose dialog to be opened at any one time.

  • 0

I want only one folder choose dialog to be opened at any one time.
Once the user selected the folder an event will be fired inform the javaScript of the selected folder.

To open the dialog i included the code from the following gist in my project
DialogManager abstraction for FireBreath

pluginAPI cpp

I maintain a global pointer to the plugin so its functions can be called from any context

Q: is this the best way?

#include "DialogManagerWin.h"
pluginAPI * g_thePlugin;

I set it in the pluginAPI CTOR

g_thePlugin = this;

pluginAPI.h

This goes to pluginAPI

this is the event i want to give the javascript the selected folder

FB_JSAPI_EVENT(folderselected, 1, (const std::string&));

the API to call from javaScript:

calls the code from the gist to open the folder selection in another thread to avoid blocking and causing the browser to freeze.

void pluginAPI::SelectFolder(std::string initialFolderPath)
{
  FB::PluginWindow* pluginWindow = pluginAPI::getPlugin()->GetWindow();
  DialogManager* dlg_mgr = DialogManager::get();
  dlg_mgr->OpenFolderDialog(m_host, pluginWindow, folderSelectorCallback);

  return;
}

The callback

this callback will be called once the user selected a folder

void folderSelectorCallback(const std::string& folderSelected)
{
    g_thePlugin->fire_folderselected(folderSelected);
    return ;
}
  • 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-12T07:16:51+00:00Added an answer on June 12, 2026 at 7:16 am

    First of all, there is a difference between the plugin and the root JSAPI object; you’re maintaining a global pointer to the root JSAPI object.

    No, this is not a good idea and you should never do this.

    Secondly, what you probably want to do here is not to fire a JSAPI event but actually to just call an asynchronous callback. There are examples of this in FBTestPlugin and a blog post on the subject.

    All you need to do is accept a const JSObjectPtr& callback argument to the js function and then pass that into the callback from the dialog abstraction.

    If you’re using the abstraction as it is in the gist, it’d look something like this:

    void MyPluginAPI::someJavascriptMethod(const FB::JSObjectPtr& callback) {
        PathCallback dlgCallback = boost::bind(MyPluginAPI::doCallback, this, callback, _1);
        DialogManager::get()->OpenFolderDialog(m_host, getPlugin()->GetWindow(), dlgCallback);
    }
    
    void MyPluginAPI::doCallback(const FB::JSObjectPtr& callback, const std::string& path) {
        callback->InvokeAsync("", FB::variant_list_of(path));
    }
    

    Haven’t tested that code exactly, but that should be close.

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

Sidebar

Related Questions

We only want one instance of our app running at any one time. So
If I have Model.objects.all() I want to get only one object for any content_object=foo,
I want to save a query only one time in the database, this is
i want to move only zip file from one folder to another folder everyday.
I want to select only one radio button but I cant do this. Here
i have a page that contains several submit buttons however i only want one
I have a several processes node.js. I want to only add one string to
I have two sites with different SITE_IDs, but I want to have only one
I have a two UIViews filled with UIButtons. I want to only allow one
Play with it here: http://jsbin.com/ocicu4/4/edit Simple Accordion, I only want one section open at

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.