InputDialog, when using DialogActions.OK_CANCEL, set OK as primary and with CTRL-ENTER shortcut

Hi

When using a very simple InputDialog like below, is it possible to set by default OK as primary (blue) and CTRL-ENTER as keyboard shortcut to activate primary button without using the mouse.

If you want the same behavior everywhere in your app, you can never use “withActions(DialogActions)” builder method.

 dialogs.createInputDialog(this)
                        .withParameters(InputParameter.parameter(DOCUMENT_PARAM).withField(() -> getTemplateField(list)))
                        .withCaption(messages.getMessage(IBusyStandardEditor.class, "createInputDialog.template.caption"))
                        .withActions(DialogActions.OK_CANCEL)
                        .withCloseListener(this::executeDocument)
                        .build()
                        .show();

Regards
Michael

Hello,

Thank you for the feedback! I’ve created an issue in the repository Haulmont/jmix-ui#777.

Thanks @Pinyazhin

Is there a way to extend Dialogs component ? I have several behaviors of dialog builders that I would like to change, including this shortcut issue.

It is not a classical bean so it cannot be extended like them.

If it cannot be extended at all I will use another trick (decorator on builders), but this is less convenient and prone to error.

Michael

The only way is to extend AppUI class and override setApplicationContext() method:

public class CustomAppUI extends AppUI {

    @Inject
    @Override
    protected void setApplicationContext(ApplicationContext applicationContext) {
        super.setApplicationContext(applicationContext);

        CustomWebDialogs customWebDialogs = new CustomWebDialogs(this);
        autowireContext(customWebDialogs, applicationContext);
        setDialogs(customWebDialogs);
    }
}

Custom WebDialogs:

public class CustomWebDialogs extends WebDialogs {

    public CustomWebDialogs(AppUI ui) {
        super(ui);
    }
}

Registration of custom AppUI in the web-spring.xml:

<bean id="cuba_AppUI" class="com.company.my_app.web.CustomAppUI" 
      scope="prototype"/>

Got it, thanks @Pinyazhin

Michael