Skip to main content
btempleton1982
Inspiring
March 9, 2016
Answered

Show / hide panel programmatically

  • March 9, 2016
  • 1 reply
  • 793 views

I have a custom menu item that I'd like to show and hide my HTML5 panel.

Currently I have the "Show" part working via the sAICSXSExtension->LaunchExtension() function.

I am trying to "Hide" using the HTMLController->UnloadExtension() function. The HTML guts of my panel are hidden this way, but the panel frame persists. Hitting "Show" again does not bring the guts back. If I close the empty panel frame, then I select "Show" once and it does nothing. I select "Show" again, an it reloads the whole panel with HTML contents.

What am I doing wrong?

This topic has been closed for replies.
Correct answer Toto RoToTO

I had the same issue. So here is the workaround I finally used.

The HTMLController does not unload itself. A message is sent to extension to make it done by the extension itself.

//Plugin controller:

static void UnloadPanelFunc(const csxs::event::Event* const eventParam, void* const context)

{

    myPanelController *controller = (myPanelController *)context;

    do {

        //Check first if your panel is ready and connected

        AppContext appContext(gPlugin->GetPluginRef());

        myPanelController->forceUnloadExtension();

    } while (false);

}

void

myController::forceUnloadExtension(){

    this->SendMessage(EVENT_TYPE_PRODUCT_PANEL_FORCE_UNLOAD, "forceUnload", "blabla");

}

Extension, message received callback:

case "EVENT_TYPE_PRODUCT_PANEL_FORCE_UNLOAD":


  var csinterface = new CSInterface();

  csinterface.closeExtension();

  //"we are doing some hack here (closing window extenstion with cs interface"
  };

Voila,

Thomas.

1 reply

Toto RoToTO
Toto RoToTOCorrect answer
Inspiring
March 10, 2016

I had the same issue. So here is the workaround I finally used.

The HTMLController does not unload itself. A message is sent to extension to make it done by the extension itself.

//Plugin controller:

static void UnloadPanelFunc(const csxs::event::Event* const eventParam, void* const context)

{

    myPanelController *controller = (myPanelController *)context;

    do {

        //Check first if your panel is ready and connected

        AppContext appContext(gPlugin->GetPluginRef());

        myPanelController->forceUnloadExtension();

    } while (false);

}

void

myController::forceUnloadExtension(){

    this->SendMessage(EVENT_TYPE_PRODUCT_PANEL_FORCE_UNLOAD, "forceUnload", "blabla");

}

Extension, message received callback:

case "EVENT_TYPE_PRODUCT_PANEL_FORCE_UNLOAD":


  var csinterface = new CSInterface();

  csinterface.closeExtension();

  //"we are doing some hack here (closing window extenstion with cs interface"
  };

Voila,

Thomas.

btempleton1982
Inspiring
March 10, 2016

Thanks, that seems to work perfectly.

I have arrived at the following code to show and hide my panel from the menu item:

In Plugin::GoMenuItem()

if ( message->menuItem == MyMenuItemSelected )

  {

        AIBoolean state;

        sAICSXSExtension->IsPrimaryStageVisible(MY_UI_EXTENSION, state);

        if (state == TRUE)

        {

            MyUIController->SendCloseMessageToHtml();   //Sends event to HTML which triggers csInterface.closeExtension();

        }

        else

        {

            MyUIController->LoadExtension();   //This seems to be needed so that the menu item loads the panel on the first click instead of requiring two clicks

            sAICSXSExtension->LaunchExtension(MY_UI_EXTENSION);

        }

  }