cancel
Showing results for 
Search instead for 
Did you mean: 

Popup with return value

CHech.1
Associate III

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

3 REPLIES 3
Osman SOYKURT
ST Employee

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

Osman SOYKURT
ST Software Developer | TouchGFX

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

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

Osman SOYKURT
ST Software Developer | TouchGFX