- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 sap.m.Popover作为某些控件的“丰富工具提示”。这是根据 SAP 的建议,因为 sap.ui.commons 库现已弃用。我们想要添加到标准字符串工具提示中的文本太多。我还没有找到直接将弹出窗口用作工具提示的方法,这就是我扩展 TooltipBase 的原因控件来处理弹出框。
我的弹出窗口工作正常,但是当我与我的控件交互时,出现以下错误:
Uncaught Error: failed to load 'myNewToolTip/controls/TooltipBaseRenderer.js' from ../controls/TooltipBaseRenderer.js: 404 - Not Found
我从这些看到threads这是因为 TooltipBase 类是一个抽象类,因此没有渲染器。但是,因为我已经在使用弹出窗口,所以我不需要渲染任何东西。我试图添加 TooltipBaseRenderer.js 并且只有一个空的渲染类。但 UI5 也不喜欢那样。
我的问题是我应该怎么做,我看到两个选项:
这是我当前的自定义控件源代码:
sap.ui.define([
"sap/m/Popover"
], function (Popover) {
"use strict";
return sap.ui.core.TooltipBase.extend("myNewToolTip.TooltipBase", {
metadata: {
properties: {
title : {}
},
events: {
"onmouseover" : {},
"onmouseout" : {}
}
},
oView: null,
setView: function(view) {
this.oView = view;
},
onmouseover : function(oEvent) {
var that = this;
if (!this.delayedCall){
this.delayedCall = setTimeout(function() {
if (!that.oPopover){
that._createQuickView();
}
}, 500);
}
},
onmouseout: function(oEvent) {
if (this.oPopover){
this.closePopover();
this.delayedCall = undefined;
}
else{
clearTimeout(this.delayedCall);
this.delayedCall = undefined;
}
},
_createQuickView: function() {
var sTitle = this.getTitle();
this.oPopover = new Popover({
title: sTitle
});
this.oPopover.openBy(this.getParent());
},
closePopover: function(){
this.oPopover.close();
this.oPopover = undefined;
}
});
});
最佳答案
无需创建自定义控件来在鼠标悬停时显示弹出窗口。正如你所说,有一个更简单的方法:Adding event delegates .
events that delegates can listen to 之一是 onmouseover
可以这样实现:
this.byId("myTargetControl").addEventDelegate({
onmouseover: function () {
// Open popover here
}
});
演示: https://embed.plnkr.co/jAFIHK
sap.ui.core.TooltipBase
如果您仍然考虑扩展 TooltipBase(没有 Popover),请看一下这个示例: https://embed.plnkr.co/33zFqa?show=control/MyCustomTooltip.js,preview
但请记住,工具提示通常不应包含关键信息,因为它缺乏可发现性,如 Fiori Design Guideline mentions
Tooltips (...) should never contain critical information. They should also not contain redundant information.
就像一个友好的提醒:)不要让人们徘徊寻找东西。
关于SAPUI5 使用 Popover 作为工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45475348/
我正在使用 sapui5 创建一个表。我想知道我是否可以将升序排序和降序排序的默认图标更改为我自己的图标? 补充问题:有没有一种方法可以在标题中显示我的自定义图标而无需先点击它? 最佳答案 只需在 W
我如何在 SapUI5 中构建一个 XML View 来迭代 JSONModel 中的所有元素? 到目前为止,我有一个 Controller : sap.ui.define([ "sap/ui
我是一名优秀的程序员,十分优秀!