我正在使用 HTML5 Canvas 。我已将图像 (BitmapImages) 添加到 Canvas ,现在我想向这些位图图像添加简单的工具提示。
这可能吗???如果可以,有人可以告诉我/告诉我如何实现这一目标吗?
我不确定它是否有所作为,但我也在使用 Easel JS 框架......
这是我目前拥有的示例:
var container = new Container(); // EaselJS Container
container.x = 100;
container.y = 100;
stage.addChild(container);
var image = new Image();
image.src = "image.png";
var bitmap = new Bitmap(image);
bitmap.x = 5;
bitmap.y = 5;
bitmap.mouseEnabled = true;
container.addChild(bitmap);
...
我没有测试过这段代码,但基本上是创建了一个位图图像并将其添加到我的舞台上。我现在想向我的位图图像添加一个简单的工具提示,但似乎无法弄清楚如何:(
如有任何帮助,我们将不胜感激。
干杯, 乔恩。
最佳答案
这是我的做法:
stage.enableMouseOver();
bitmap.onMouseOver = function(e) {
stage.canvas.title = 'put your tooltip text here';
}
bitmap.onMouseOut = function(e) {
stage.canvas.title = '';
}
这通过使用浏览器已经提供的工具提示来实现。
关于javascript - HTML5 Canvas 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11437211/