Modal popup screen
dnahman
Posts: 28
Hi there,
Is there any way to throw up a popup screen and have the channel of the button press passed back to the calling function, rather than having to define a button_event for the buttons on the screen itself?
I'm looking for something similar to the Microsoft function MessageBox(), which puts up a dialog box which allows the calling function (and thread) to block until the box is dismissed.
eg:
if ( MessageBox("Really erase your hard disk") == ID_YES) {
// reformat disk
}
Right now I'm doing this in netlinx with a global variable that tells the button event on a generic confirmation box which function to run, and other global variables for each of the functions to pick up, but this is too messy.
Any hints would be appreciated.
thanks
David
Is there any way to throw up a popup screen and have the channel of the button press passed back to the calling function, rather than having to define a button_event for the buttons on the screen itself?
I'm looking for something similar to the Microsoft function MessageBox(), which puts up a dialog box which allows the calling function (and thread) to block until the box is dismissed.
eg:
if ( MessageBox("Really erase your hard disk") == ID_YES) {
// reformat disk
}
Right now I'm doing this in netlinx with a global variable that tells the button event on a generic confirmation box which function to run, and other global variables for each of the functions to pick up, but this is too messy.
Any hints would be appreciated.
thanks
David
0
Comments
I think this will accomplish what you require.
Jeff
As I understand it, the modal option will force all presses to be directed to the modal popup. But at that point the calling function will have exited (since it knows nothing about the status of the touchpanel after it sends the PPN command).
I'm looking for some way to direct the button press event back to the calling function which is blocking until the modal box is dismissed.
Is there some other option that I'm missing here?
thanks
david
SOME_EVENT:
{
PUSH:
{
Whatever code;
SEND_COMMAND dvTP,"'^TXT-1,0,',POPUP_MESSAGE" //Set text to indicate popup page function
SEND_COMMAND dvTP,"'@PPN-MODAL'" //Display Popup Page
WAIT_UNTIL (nMODAL_YES == 1) 'MODAL'
{
SEND_COMMAND dvTP,"'@PPF-MODAL'"
nMODAL_YES = 0
...Execute FUNCTION 1...
}
}
}
SOME_OTHER_EVENT:
{
PUSH:
{
Whatever code;
SEND_COMMAND dvTP,"'^TXT-1,0,',POPUP_MESSAGE2" //Set text to indicate popup page function
SEND_COMMAND dvTP,"'@PPN-MODAL'" //Display Popup Page
WAIT_UNTIL (nMODAL_YES == 1) 'MODAL'
{
SEND_COMMAND dvTP,"'@PPF-MODAL'"
nMODAL_YES = 0
...Execute FUNCTION 2...
}
}
}
BUTTON_EVENT[dvTP,MODAL_BTN_YES]
{
PUSH:
{
nMODAL_YES = 1
}
}
BUTTON_EVENT[dvTP,MODAL_BTN_NO]
{
PUSH:
{
SEND_COMMAND dvTP,"'@PPF-MODAL'"
CANCEL_WAIT_UNTIL 'MODAL'
}
}
Because the WAIT_UNTIL is named, only 1 instance will be created. You just put different function calls into the wait depending on which event created the need for the modal. This would allow multiple functions to use the same modal page. Because the Popup is MODAL, you don't have to worry about other buttons being pushed until a button is pushed on the modal popup. You might need to set a variable to track if a TP is in modal mode tho if you deal with touchpanels that turn off or loose connection. Basically if the modal mode is not active, send normal ONLINE event commands to the panel. If modal mode is active, send the command to display the popup on the touchpanel.
If you need to track modal active mode, just create an array of modal messages and set the value of the modal_active variable to point to the appropriate message. This way when you send the command to display the modal popup, you can send the appropriate message to the popup so the user knows what condition they are responding to.
If I am completely missing the target again, code you post a snippet of code or an example of an event and resulting processes?
Jeff
I can basically wrap that all in a MessageBox() function that takes the message string and returns a yes or no code and call it a day.
Thanks for your help!
--david
But still, the code that you gave me is *way* cleaner than what I had. I was able to rip out gobs of nasty spaghetti code that had been bothering me for some time.
By having both the yes and no buttons in an array, and having them set a non-zero code to the nMODAL_YES variable via get_last, I was able to have both buttons share a button_event handler and lop a few more lines out the code (and remove the cancel_wait_until line).
If I ever needed to have more buttons on the modal dialog, this will scale painlessly.
Thanks again for your help!
david
Jeff