Default button setting has no influence

It does not matter for which button I define "default button" for the dialogs, in the dialog shown due to the executed script the button, which was created first has the focus.

E.g. this script snippet calls the dialog "delete":

				Dlg.window = tab;
				Dlg.icon = "question";
				Dlg.top = true;
				Dlg.template = "delete";
				Dlg.detach = true;
				Dlg.Create();
				Dlg.Control("archname").label = "<" + item.name + ">";				
				var retVal2 = Dlg.RunDlg();

In the dialog editor the button "No for all" ist set to default.

But when I run the script "Yes" is default:
Script

Do I have to define the default button also via script or read out the value from the ressources?

The default button is a Windows concept, It is the button which will be activated when Return is pushed if no other button has focus (and if the control with focus doesn't use Return for something else, e.g. a multi-line edit control).

It doesn't have anything to do with which control has focus when the dialog opens.

You can also only have one default button, so make sure the Yes button doesn't also have the default option turned on.

So the default button would only be activated when I manually remove the focus from any button and push then return? E.g. when I click on a radio button and push then return the default button will be used?

So I have to define which button/control has the focus via script command?

Yes is not defined as default button.

I think it would be helpful to make this more clear in the manual. That it only works if no (other) button has the focus.
I thought this button will be chosen when I press Return without changing or selecting anything in a dialog.

The default button and the focus are separate, but related, concepts.

Fundamentally the default button is the button that gets "pressed" when you press the enter key.

The focus can be moved around from one control to another, without the default button changing.

However, if the focus moves to a button (rather than e.g. a checkbox or an edit control), that button becomes the default button temporarily.

The "real" default button is restored when the focus goes to a non-button control.

You can set which button is the default button via the property in the dialog editor.

The first control in the dialog's z-order will have focus by default; this may or may not be the default button.

To change the order that controls get focus (i.e. the order that the focus moves when you push the tab key) press Ctrl-D in the dialog editor.

There's a bit more explanation of the concept here.

4 Likes

Thank you. :slight_smile: A clear and precise answer that contains all the necessary information. :+1:

Ah, the button "Tab Order". But the key combination is (at least for German language) CTRL+D.
That worked.