2025-11-24 12:04 PM
Hello,
I'm currently building an application with TouchGFX that has many screens. We don't have a touchscreen, and only use hardware buttons. My application requires that if a trouble code is detected on the vehicle bus, relevant information should popup on the screen. The popup takes over the screen, and button presses that the user enters are handled by the popup instead of the previously open screen. The user can acknowledge the trouble code by pressing a hardware button which will make the popup go away and return to the screen that had been previously open. If multiple trouble codes are active simultaneously the highest priority trouble code will show up first. Pressing the acknowledge button will cause the next highest priority trouble code to show up until all active codes have been acknowledged, at which point the popup will go away and return to the screen that had been previously open. I've thought through two possible implementations for this problem and neither works perfectly.
The first option is to have a "Popup" View/Presenter. When the Model detects a trouble code it calls a ModelListener::reportPopup() function that, among other things, calls the MVPApplication::makeTransition() to transition to the "Popup" View/Presenter. This works great for getting to the popup screen. But because MVPApplication::makeTransition uses a template that takes the Screen and Presenter types as parameters (which get expanded at compile time) I'm unable to set up a call to MVPApplication::makeTransition() at runtime to return to the original screen.
The second option I looked into was to create a custom "Popup" container that I add to all my screens. The popup is hidden by default, and the Model calls some Presenter function to show the "Popup" container when necessary. The problem with this is that I a) have to add the container to every single one of the screens (which would lead to lots of duplicate code and could potentially lead to problems with future maintenance) and b) the container doesn't allow me to override the hardware button interactions when it's active except by virtual functions (which again would lead to lots of duplicate code and could potentially lead to problems with future maintenance).
I think my ideal solution would be the first option, where the Model (through the Presenter) calls the MVPApplication::makeTransition() function to activate the popup screen when reported and then restore the original screen when all trouble codes are acknowledged. Are there any good solutions for this? Thanks!