Script Dialog Default

I created a simple script to see what happens when a dialog item is set to default. Here is the script button code..

option explicit Function OnClick(ByRef ClickData) Dim cdf, dlg, i, list, menu Set list = DOpus.NewVector : Set menu = DOpus.NewVector Set cdf = ClickData.Func : Set dlg = cdf.Dlg list(0) = "Default Option" : menu(0) = 3 ' Make this the checked default selection list(1) = "First Non-Default Option" : menu(1) = 0 list(2) = "Second Non-Default Option" : menu(2) = 0 list(3) = "Etc.." : menu(3) = 0 With dlg .choices = list .menu = menu .show i = dlg.result End With DOpus.output "dlg.show returned a value of " & i End Function
The resultant dialog looks like this..


If I press ESC the debug output is dlg.show returned a value of 0, which is as expected.
If I click item 1 (the default) the output is dlg.show returned a value of 1 as expected.
If I click item 2 the output is dlg.show returned a value of 2 as expected.
Etc.

However, if I press ENTER the output is dlg.show returned a value of 0 which is unexpected. Since item 1 is clearly defined as the default, I would expect ENTER to behave as if I had clicked the default item.

Regards, AB

Default just means bold if we're talking about a pop-up menu. It has no effect on what the enter key does.

You'd have to push a cursor key first to select one of the menu items before enter could activate one of them.

Perhaps the dialog.selected could be extended to support menus. Though I' not sure a default selected item on a menu makes sense.

It would definitely be non-standard.

Try using the context menu key on the desktop, or in an Explorer window, for example. The context menu opens with no item selected. If you hit return in that state, it cancels the menu. Same with all standard context menus, I think.