Skip to main content
CHech.1
Associate III
December 19, 2021
Question

Popup with return value

  • December 19, 2021
  • 3 replies
  • 1264 views

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

This topic has been closed for replies.

3 replies

Osman SOYKURT
ST Technical Moderator
February 17, 2022

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

ST Software Developer | TouchGFX
BBlad.1
Associate II
February 17, 2022

We did a something similar, with the addition of the option to provide callbacks when ok/cancel are clicked.

Osman SOYKURT
ST Technical Moderator
February 17, 2022

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".

0693W00000KZaNRQA1.png/Osman

ST Software Developer | TouchGFX