Read-only archive of the All About Symbian forum (2001–2013) · About this archive

Switching to other app causes dialog 'OK' event

1 replies · 2,153 views · Started 01 February 2005

Situation: I have an app (on the P900) that synchronizes data between the PDA and an external database. This app displays a dialog to allow the user to change settings. This dialog has two buttons: OK and Cancel (with the default IDs). The Cancel button is the default button. When the user presses the OK button, the synchronization process starts:


button_id = dlg->ExecuteLD(dialog_resource);
if ( button_id == EEikBidOk )
{
// Start the sync process
}

No problem so far. However, when the user switches to another application while the dialog is shown, the dialog returns with button id EEikBidOk. Which causes the synchronization process to start...

I tried redefining the HandleForegroundEventL method, and set a flag when the application goes to the background, and only start the sync process when the application is in the foreground, but apparently this method gets called after the dialog returns...

Is there a way to detect if the dialog returned because the user actually pressed a button, or because the application was switched to the background?

-- arno

that's the default behaviour. i found this out only after a while! you have 2 options. either you implement an obscurely documented member that prevents the dialog from shutting down OR you define your own buttons that use other button ids. would be best to define your OWN button ids too.

the problem isn't that the OK button is pressed but more like that EEikBidOk is returned to OkToExitL() when the dialog is dismissed in the manner you described. by defining your own button ids, you can specifically check for your id of the OK button.