Skip to content

Commit

Permalink
feat(views): the 'onViewChanged' Lua event now notifies the old and n…
Browse files Browse the repository at this point in the history
…ew views
  • Loading branch information
mwerle committed Nov 19, 2024
1 parent 2c2b5be commit a239cab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,10 +1218,15 @@ void Pi::RequestQuit()
void Pi::SetView(View *v)
{
// TODO: Should it be an error or warning to switch the view to itself?
View *previousView = currentView;

if (currentView) currentView->Detach();
currentView = v;
if (currentView) currentView->Attach();
LuaEvent::Queue("onViewChanged");
LuaEvent::Queue("onViewChanged",
currentView? currentView->GetViewName().c_str() : "",
previousView? previousView->GetViewName().c_str() : "");

}

bool Pi::SetView(const std::string& target)
Expand Down

0 comments on commit a239cab

Please sign in to comment.