Thank you, glad I could help
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
int main()
{
// create graphics manager
sf::RenderWindow m_window;
sf::VideoMode DesktopMode = sf::VideoMode::getDesktopMode();
m_window.create(DesktopMode, "My window");
// create gui manager
tgui::Gui gui(m_window);
gui.setGlobalFont(RESOURCES_PATH "gfx/courier.ttf");
// create top menu (relevant to all editing modes)
const unsigned int TOP_BAR_ID = 1;
tgui::MenuBar::Ptr menu(gui);
menu->load(gui_theme);
menu->setSize((float)m_window.getSize().x, TOP_BAR_HEIGHT);
menu->addMenu("Do Bug");
menu->addMenuItem("Do Bug", "DO IT!");
menu->bindCallback(tgui::MenuBar::MenuItemClicked);
menu->bindCallback(tgui::MenuBar::MouseEntered);
menu->setCallbackId(TOP_BAR_ID);
// the window that will contain the combobox
tgui::ChildWindow::Ptr bug_window(gui);
bug_window->load(gui_theme);
bug_window->setSize(230, 340);
bug_window->setPosition(100, 100);
bug_window->show();
tgui::ComboBox::Ptr combo;
combo->load(gui_theme);
combo->addItem("click");
combo->addItem("me");
bug_window->add(combo);
// run the program as long as the window is open
while (m_window.isOpen())
{
// start rendering frame
m_window.clear(sf::Color::Black);
// poll window events
sf::Event event;
while (m_window.pollEvent(event))
{
gui.handleEvent(event);
}
// poll gui events
tgui::Callback callback;
while (gui.pollCallback(callback))
{
if (callback.id == TOP_BAR_ID)
{
menu->moveToFront();
if (callback.trigger == tgui::MenuBar::MenuItemClicked)
{
bug_window->hide();
}
}
}
gui.draw();
m_window.display();
}
return 0;
}
QuoteIf you can get a minimal code that reproduce this then that would be nice.I will try, but know it's a very rare but (took me a while to finally catch it in debug mode lol)
QuoteDo you have a callback bound to the focus events on widgets?no.
QuoteDo you run these show and hide calls inside a function callback from a tgui widget?yes. this happens when the user select an item from a top bar and "switch" edit mode for say from editing tiles to editing objects, then I hide all the tiles-related windows and show all the objects-related windows.
QuoteDo you remove widgets somewhere or do you only hide and show them?no remove, I only create them once and I player with the visibility of the windows via hide() and show().

void Container::focusWidget(Widget *const widget)
{
// Loop all the widgets
for (unsigned int i = 0; i < m_Widgets.size(); ++i)
{
// Search for the widget that has to be focused
if (m_Widgets[i].get() == widget)
{
// Only continue when the widget wasn't already focused
if (m_FocusedWidget != i+1)
{
// Unfocus the currently focused widget
if (m_FocusedWidget)
{
m_Widgets[m_FocusedWidget-1]->m_Focused = false; // <- EXCEPTION HERE.
m_Widgets[m_FocusedWidget-1]->widgetUnfocused();
}
// Focus the new widget
m_FocusedWidget = i+1;
widget->m_Focused = true;
widget->widgetFocused();
}
break;
}
}
}