PDA

View Full Version : Cancel button on Cancel dialog does nothing



thorne
07-21-2004, 08:14 AM
I created a new Cancel dialog and gave it my own name. I added the new dialog as a Custom Dialog into the Sequences/Install/PreInstall sequence just before the Welcome dialog. The dialog displays fine during the install, but when I press the Cancel button, the install doesn't exit. Nothing seems to happen. Is there something I have to do to make pressing the Cancel button exit the install? Thanks, Thorne

brianl
07-21-2004, 02:45 PM
The Cancel frame will not work to do what you are looking for. The Cancel frame is used for dialogs that are presented by wizard actions, and the Cancel button on the frame has the effect of canceling the wizard action, not the entire install.

To provide a dialog & frame that has only a cancel button which exits the wizard, you need to

1. Add a new frame under the Dialogs view (call it "CancelWizard" or something.)
2. Add your dialog under this frame.
3. On the CancelWizard frame, add a button control and set its text to "Cancel".
4. Add a buttonClicked event to this cancel button with the following code

public void buttonClickedCancelButton(com.installshield.event.ui.ISControlContext context)
{
SwingWizardUI wizardUI = (SwingWizardUI)context.getWizardUI();
wizardUI.doCancel();
}

thorne
07-21-2004, 03:52 PM
Thanks, Brian - Cancel button still doesn't do anything. Do I have to add code to the buttonClickedISButtonDef1 method? Here's my Swing code:



public class FrameCancelInstallDialog
{

public void buttonClickedISButtonDef1(com.installshield.event.ui.ISControlContext arg0)
{

}
public void buttonClickedCancelButton(com.installshield.event.ui.ISControlContext context)
{
SwingWizardUI wizardUI = (SwingWizardUI)context.getWizardUI();
wizardUI.doCancel();
}

}

brianl
07-21-2004, 04:41 PM
Hi, thorne. Looks like you have a couple of buttonClicked events which may no longer be tied to the actual button control anymore. Try clicking the Event Browser button at the far right of the code view, and deleting any buttonClicked events you see there. This should clear out the code for those events in the code editor (and will also clear out the database for those events). Then try adding the buttonClicked event for the cancel button again.

thorne
07-21-2004, 05:02 PM
UPDATE - Got it. I had to add this code inside the buttonClickedISButtonDef1 method:



arg0.getWizard().exit(ExitCodes.NORMAL_EXIT);


Thanks, Brian. Now when I add a buttonClicked event I get this Swing code. Do I have to add code in the buttonClickedISButtonDef1 method? Pressing the Cancel button still does nothing. Thorne



public class PanelUserNotAnAdminDialog_EXIT
{

public void buttonClickedISButtonDef1(com.installshield.event.ui.ISControlContext arg0)
{
}

public void buttonClickedCancelButton(com.installshield.event.ui.ISControlContext context)
{
SwingWizardUI wizardUI = (SwingWizardUI)context.getWizardUI();
wizardUI.doCancel();
}

}

brianl
07-21-2004, 07:15 PM
FYI, getWizard().exit(ExitCodes.NORMAL_EXIT) will not display the confirmation dialog to the user asking if they are sure, which WizardUI.doCancel() will do in addition to calling Wizard.exit() if the user confirms. Which one you want depends on whether you want to display the confirmation dialog or not.

thorne
07-22-2004, 09:32 AM
Thanks again, Brian. 2 questions...

If I don't put the doCancel() code in the buttonClickedISButtonDef1 loop, nothing happens when I click the Cancel button. So I'm still a bit confused as to in which of the 2 methods I'm supposed to use your recommended code.

I'm relatively new to ISX coding. I have the training materials (I took the 4-day class), but where could I have gone to figure this stuff out for myself? I use the Advanced API's help and Helpnet, but these kinds of "which Java API's do I use in which IS contexts?" questions are overly difficult for me.

Thorne

brianl
07-22-2004, 11:04 AM
I'm not exactly sure why you don't get the exit behavior to happen with doCancel(), it's working for me. You may want to try starting over with a new frame.

A good source of info with dialog events is to look at the event code for the predefined panels and frames. For example, we know that the Cancel button on the Main frame cancels the setup, so looking at the buttonClickedcancel() event for the Main frame shows the code that will do that. Another place to look for coding help is the IS Knowledge Base, which you can search (http://support.installshield.com/default.asp#kb).

thorne
07-23-2004, 09:20 AM
message deleted - wrong thread. Thorne

wohler
03-07-2005, 07:44 PM
Brian, Thorne,

Thanks *very* much for this thread. A couple of observations:

1. It seems to me that this frame should be provided by default.

2. It seems to me that it would be more consistent with the other frames if this frame was called Cancel and the existing Cancel frame was renamed CancelAction.

3. I went with "context.getWizard().exit(ExitCodes.NORMAL_EXIT);" in the buttonClickedCancel method since if you only have a Cancel button, asking the user if they are sure seems silly.