Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Palette re-opens automatically on changing views

dushyant
Enthusiast

Hi,

I used DG::Palette for an addon and observed it auto re-opens after being closed, when I change to certain views. These are the steps to reproduce the scenario:

  1. Open the palette (from the user addon menu)
  2. Close the palette (using the close [x] button at the top-right corner)
  3. Open the Profile Manager palette and click 'Edit'
  4. Close the profile editing window.
  5. The addon palette reappears.

This can be tested with the example addon DG_Test > OwnerDrawnListBoxPalette

 

This however does not happen with the 'Favorites' palette, for example. I want the addon palette to behave like that.

 

Anyone any idea?

 

Thanks.

Dushyant

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Miklos Vegh
Graphisoft
Graphisoft

Some additional flagging is missing from the palette (DG_Test/OwnerDrawnListBoxPalette) code. The palette state should be stored before the palette temporarily goes to/comes back from hidden state due to window switching.

A static bool variable can be used to temporarily store the visibility state (paletteOpenAtClose):

GSErrCode __ACENV_CALL	OwnerDrawnListBoxPalette::PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr param)
{
	static bool paletteOpenAtClose = false;
	GSErrCode err = NoError;
	if (referenceID == OwnerDrawnListBoxPalette::ODLBPaletteRefId ()) {
		OwnerDrawnListBoxPalette& palette = OwnerDrawnListBoxPalette::GetInstance();
		switch (messageID) {
			case APIPalMsg_ClosePalette:
			case APIPalMsg_HidePalette_Begin:
				if (palette.IsVisible()) {
					paletteOpenAtClose = true;
					palette.Hide();
				} else {
					paletteOpenAtClose = false;
				}
				break;

			case APIPalMsg_OpenPalette:
				paletteOpenAtClose = true;
				// no break

			case APIPalMsg_HidePalette_End:
				if (paletteOpenAtClose && !palette.IsVisible()) {
					palette.Show ();
				}
				break;

			case APIPalMsg_DisableItems_Begin:
				palette.DisableItems();
				break;

			case APIPalMsg_DisableItems_End:
				palette.EnableItems();
				break;

			case APIPalMsg_IsPaletteVisible:
				(*reinterpret_cast<bool*> (param)) = palette.IsVisible();
				break;

			default:
				break;
		}
	}

	return err;
}

 

View solution in original post

2 REPLIES 2
Solution
Miklos Vegh
Graphisoft
Graphisoft

Some additional flagging is missing from the palette (DG_Test/OwnerDrawnListBoxPalette) code. The palette state should be stored before the palette temporarily goes to/comes back from hidden state due to window switching.

A static bool variable can be used to temporarily store the visibility state (paletteOpenAtClose):

GSErrCode __ACENV_CALL	OwnerDrawnListBoxPalette::PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr param)
{
	static bool paletteOpenAtClose = false;
	GSErrCode err = NoError;
	if (referenceID == OwnerDrawnListBoxPalette::ODLBPaletteRefId ()) {
		OwnerDrawnListBoxPalette& palette = OwnerDrawnListBoxPalette::GetInstance();
		switch (messageID) {
			case APIPalMsg_ClosePalette:
			case APIPalMsg_HidePalette_Begin:
				if (palette.IsVisible()) {
					paletteOpenAtClose = true;
					palette.Hide();
				} else {
					paletteOpenAtClose = false;
				}
				break;

			case APIPalMsg_OpenPalette:
				paletteOpenAtClose = true;
				// no break

			case APIPalMsg_HidePalette_End:
				if (paletteOpenAtClose && !palette.IsVisible()) {
					palette.Show ();
				}
				break;

			case APIPalMsg_DisableItems_Begin:
				palette.DisableItems();
				break;

			case APIPalMsg_DisableItems_End:
				palette.EnableItems();
				break;

			case APIPalMsg_IsPaletteVisible:
				(*reinterpret_cast<bool*> (param)) = palette.IsVisible();
				break;

			default:
				break;
		}
	}

	return err;
}

 

dushyant
Enthusiast

@Miklos Vegh  That works perfectly! Thanks a tonne!!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!