如果 sap.ui.table 的单元格是输入类型,如何注册上下文菜单事件
How to register contextmenu event if cell of sap.ui.table is of type input
我尝试在输入类型为 table 的单元格上获取上下文菜单。
鼠标右键只对输入框以外的部分有效
有没有办法将输入字段中的事件正确分配到下面的单元格中?
此外,输入字段上似乎没有点击事件。
我的尝试可以在plnkr中看到
https://plnkr.co/edit/BMozXm7uRPNlgzUf
编码:
<t:Table rows="{/}" visibleRowCount="100"
minAutoRowCount="10" visibleRowCountMode="Auto" id="table0"
filter="onTableFilter" class="sapUiNoMargin sapUiNoContentPadding"
beforeOpenContextMenu="onContextMenu">
<t:columns>
<t:Column width="4em" filterProperty="CompCode"
sortProperty="CompCode" resizable="true" autoResizable="true"
class="sapUiLargeNegativeMarginBeginEnd"
click="oninputclick"
press="oninputclick">
<Label text="Comp Code" wrapping="true" class="test_maybe_he"/>
<t:template>
<Input value="{CompCode}" class="test_maybe_he" click="oninputclick"
press="oninputclick"/>
</t:template>
</t:Column>
我在 table 标签中有 beforeOpenContextMenu="onContextMenu"。
然后在input标签中点击="oninputclick" press="oninputclick".
右键单击仅在输入字段外注册。 (在带有文本标签的 sapui5 示例中,它似乎有效。)
我建议使用继承自 sap.m.Input
的自定义控件。
此控件应有一个新事件(例如 rightPress
),并且应在触发本机浏览器事件 onContextMenu
时触发此事件。此外,不应显示本机上下文菜单。
sap.ui.define([
"sap/m/Input"
], function (Input) {
"use strict";
return Input.extend("gsan.ruleedit.control.MyInput", {
metadata: {
events: {
rightPress: {}
}
},
renderer: {},
oncontextmenu: function(oEvent) {
this.fireRightPress();
oEvent.preventDefault();
}
});
});
然后您可以像使用任何其他控件一样使用您的自定义控件
<mvc:View xmlns:my="gsan.ruleedit.control"
... />
<my:MyInput value="{CompCode}" rightPress="onContextMenu" />
我尝试在输入类型为 table 的单元格上获取上下文菜单。 鼠标右键只对输入框以外的部分有效
有没有办法将输入字段中的事件正确分配到下面的单元格中? 此外,输入字段上似乎没有点击事件。
我的尝试可以在plnkr中看到
https://plnkr.co/edit/BMozXm7uRPNlgzUf
编码:
<t:Table rows="{/}" visibleRowCount="100"
minAutoRowCount="10" visibleRowCountMode="Auto" id="table0"
filter="onTableFilter" class="sapUiNoMargin sapUiNoContentPadding"
beforeOpenContextMenu="onContextMenu">
<t:columns>
<t:Column width="4em" filterProperty="CompCode"
sortProperty="CompCode" resizable="true" autoResizable="true"
class="sapUiLargeNegativeMarginBeginEnd"
click="oninputclick"
press="oninputclick">
<Label text="Comp Code" wrapping="true" class="test_maybe_he"/>
<t:template>
<Input value="{CompCode}" class="test_maybe_he" click="oninputclick"
press="oninputclick"/>
</t:template>
</t:Column>
我在 table 标签中有 beforeOpenContextMenu="onContextMenu"。 然后在input标签中点击="oninputclick" press="oninputclick".
右键单击仅在输入字段外注册。 (在带有文本标签的 sapui5 示例中,它似乎有效。)
我建议使用继承自 sap.m.Input
的自定义控件。
此控件应有一个新事件(例如 rightPress
),并且应在触发本机浏览器事件 onContextMenu
时触发此事件。此外,不应显示本机上下文菜单。
sap.ui.define([
"sap/m/Input"
], function (Input) {
"use strict";
return Input.extend("gsan.ruleedit.control.MyInput", {
metadata: {
events: {
rightPress: {}
}
},
renderer: {},
oncontextmenu: function(oEvent) {
this.fireRightPress();
oEvent.preventDefault();
}
});
});
然后您可以像使用任何其他控件一样使用您的自定义控件
<mvc:View xmlns:my="gsan.ruleedit.control"
... />
<my:MyInput value="{CompCode}" rightPress="onContextMenu" />