Skip to content

Commit 0c8eb10

Browse files
committed
Update exit menu item to hide window on click
Changed the exit menu item's click handler to hide the current window instead of destroying all windows via the window manager. This simplifies the exit logic and ensures only the relevant window is closed.
1 parent f8ed4f8 commit 0c8eb10

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/window_example/main.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,11 @@ int main() {
282282
// Add exit item
283283
auto exit_item = std::make_shared<MenuItem>("Exit", MenuItemType::Normal);
284284
exit_item->AddListener<MenuItemClickedEvent>(
285-
[&window_manager](const MenuItemClickedEvent& event) {
285+
[window_ptr](const MenuItemClickedEvent& event) {
286286
std::cout << "Exit clicked from context menu" << std::endl;
287-
// Get all windows and destroy them to trigger app exit
288-
auto windows = window_manager.GetAll();
289-
for (auto& window : windows) {
290-
window_manager.Destroy(window->GetId());
287+
// Close the window to trigger app exit
288+
if (window_ptr) {
289+
window_ptr->Hide();
291290
}
292291
});
293292
context_menu->AddItem(exit_item);

0 commit comments

Comments
 (0)