如何通过 UI5 中的 XML-template override/disable "escapeHandler" of "Dialog"?

How to override/disable "escapeHandler" of "Dialog" via XML-template in UI5?

我知道在 UI5 中通过控制器覆盖 sap.m.DialogescapeHandler 的默认行为,例如:

this._oDialog.setEscapeHandler((oEscapeHandler) => {
    oEscapeHandler.reject();
});

问题是可以通过 XML 模板提供替代 escapeHandler 行为而不使用 setEscapeHandler 吗?

理想情况下,它应该类似于 escapeHandler = "none/customFunction",例如:

<Dialog
    id = "authDialog"
    title = "{i18n>DIALOG_TITLE}"
    type = "Message"
    escapeHandler = "%CUSTOM_ESCAPE_HANDLER%">
</Dialog>

特别是,我想在 Esc 按钮按下时禁用 Dialog 关闭,并通过 XML-template 以优雅、声明的方式执行此操作,例如escapeHandler = "none".

我通过放置 属性 escapeHandler = "customFunction" 然后在控制器中添加一个没有实现的函数解决了这个问题。基本上在 customFunction 我有一条评论解释说这是用来覆盖默认转义行为的。

有一个 new commit(今天合并)可以将控制器功能分配给 escapeHandler。这样,下面的代码现在就可以了:

<Dialog xmlns="sap.m"
  id="authDialog"
  title="{i18n>DIALOG_TITLE}"
  type="Message"
  escapeHandler=".handleEscape"
>
handleEscape: function(pEscapePending) {
  // Depending on the use case, call pEscapePending.resolve() or pEscapePending.reject() to overwrite the default behavior.
},

1.86 版本应该可以使用此修复程序。