void Function()
{
for(int i = 0; i < count; ++i)
{
if(check_i( int_array[i] ) )
function_gui( i );
}
}
In the code above I'm checking in the array for some particular values, when it is valid i have to display it on GUI dialog, with some text box and next button on. here I wants that the iteration in the Function() continues only after the next button is pressed else it should wait for the button to be pressed. I have read somethings about the busy waiting using semaphore. But please let me know any standard way for implementing this.
I need this in GUI app, where the value of i is displayed on the TextBox from the loop, and I wants the loop to continue only when next button is pressed else it remain pause.
Normally such functions provide the means to stay open and return the appropriate code when a button like "Cancel" is pushed.
For example, Qt's QDialog has a method called exec(). This open the dialog and block the application until is is closed with a rejection or acception. exec() then returns either QDialog::Accepted or QDialog::Rejected.
Thanks for your reply first! Yeah you are absolutely right! But in my case things are bit different.
I am using JUCE for the GUI but its not in standalone application as I am using this for making plug-In.
And My scenario is bit different, and I have written such to make the thing simpler.
I have function which puts text in a text frame and enables all the control on the panel(MODALESS DIALOG) and keep on putting the text on it. I want to intercept the loop so that It continues only when some buttons on the panel gets pressed.
And I want to be suggested with some standard way of handling this situation.
But that's exactly what the dialog should do for you. The dialog should NOT return until the user clicks on a button. This is meant by "block the application". The loop CANNOT continue unless the dialog is closed. What I suspect is: You want the dialog to be visible all the time right? The let the loop continue, update the text in the dialog - all while the dialog is shown. Correct? Or is it acceptable for you to close the dialog in between invocations in the loop?
I can't figure out if "MODALESS DIALOG" means modal or non-modal. Do you want a modal dialog? I suggest that you do use a modal dialog.
Is the user supposed to enter text in the dialog or are you simply filling the TextBox within the dialog yourself?