3

我想在 webos 应用程序中添加图像并想为其添加点击事件。我也无法在应用程序中放置背景图像。我将此代码用于在 Basic.css 文件中设置背景图像

body.palm-default {
    background: url('../images/comman_bg.png') top left no-repeat;
    z-index: -1;
    position: fixed;
    top: 0px;
    left: 0px;
    width: 320px;
    height: 480px;
}
/* "splash" below is the scene name. Replace it with your scene name to get it to have a custom background */
#mojo-scene-splash-scene-scroller {
    background: url('../images/splash-screenshot-default.png') top left no-repeat;
}

如果有人有设置图像的代码和图像的单击事件,请回复。

4

2 回答 2

1

您是否确保包含 index.html 中的 Basic.css 文件?您是否确保图像的路径正确,相对于 CSS 文件的位置?

要为图像设置点击处理程序,您需要执行以下操作:

this.onTapHandler = this.onTap.bind(this);
Mojo.Event.listen($("myImg"), Mojo.Event.tap, this.onTapHandler);

稍后你会想停止听

Mojo.Event.stopListening($("myImg"), Mojo.Event.tap, this.onTapHandler);
于 2011-08-03T13:58:21.047 回答
1
   // set up the image view widget
   this.tfdImages = this.controller.get("tfd-images");
   this.tfdWidget = this.controller.setupWidget("tfd-images", {noExtractFS: true}, this.imageModel = 
                           {
                              onLeftFunction: function() { this.updateImages(-1); }.bind(this),
                              onRightFunction: function() { this.updateImages(1); }.bind(this)
                           });
于 2011-08-12T12:54:01.830 回答