2021-12-19 01:51 AM
Hi,
I'd like to have a popup in my app, in which the user can press "Confirm" or "Cancel".
I'm looking for a way to have my code written like this:
popup_res = show_popup();
if(popup_res == true){
/* user clicked on 'confirm'. do something */
}
else{
/* user clicked on 'cancel'. do something else*/
}
Is there a way to do it?
I know that touchgfx is single threaded, so I think that I have to finish the function to refresh the screen.
But on the other hand, I know that GUI frameworks such as JavaFX are also single threaded, yet support this behaviour.
Thank you
2022-02-17 07:01 AM
Hello CHech.1,
The easiest way to have something like this would be to add some widgets to your screen (for a popup it would be like a box, 2 buttons, and a textArea), and play with them with the setVisible() function. If you want to use it in multiples screens, the best way would be to create a custom container that you'd call "popup" and use it in your screens. You can follow this tutorial if you begin with custom containers.
/Osman
2022-02-17 07:37 AM
We did a something similar, with the addition of the option to provide callbacks when ok/cancel are clicked.
2022-02-17 10:26 AM
Ok cool if you have succeeded on it :)
By the way, just remembered, we actually have a example in TouchGFX Designer about popup, it's called "ModalWindow Example".
/Osman