我知道在UI5中通过控制器覆盖sap.m.Dialog
的escapeHandler
的默认行为,例如:
this._oDialog.setEscapeHandler((oEscapeHandler) => {
oEscapeHandler.reject();
});
问题是,在不使用setEscapeHandler
的情况下,是否可以通过XML模板提供另一种escapeHandler
行为?
理想情况下,它应该是类似escapeHandler = "none/customFunction"
的东西,例如:
<Dialog
id = "authDialog"
title = "{i18n>DIALOG_TITLE}"
type = "Message"
escapeHandler = "%CUSTOM_ESCAPE_HANDLER%">
</Dialog>
特别是,我想禁用Dialog
关闭Esc按钮,并通过XML模板(例如escapeHandler = "none"
(以优雅、声明的方式执行。
有一个新的提交(今天合并(,可以将控制器函数分配给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版本中使用。
我通过放置属性escapeHandler = "customFunction"
,然后在控制器中拥有一个没有实现的函数来解决这个问题。基本上在customFunction
中,我有一条注释解释说这是用来覆盖默认转义行为的。