三星电视SDK中的CAPH API小部件

CAPH API widgets in Samsung TV SDK

本文关键字:API 小部 CAPH 中的 电视 SDK 三星      更新时间:2023-09-26

我做了一个非常简单的CAPH项目,它由一个包含图像的3x3页面组成。当我在图像上focus时,我希望能够做一些事情。到目前为止,我已经阅读了文档,但无法理解。

我想做的只是在聚焦时减少图像的opacity

这是需要编辑的代码:

page1_page.prototype.image_3fzrc_onfocus = function()
{
    //should reduce image opacity but don't know how to reference the image
}

谢谢。

PS:我使用了视觉编辑器

编辑:我做了这样的事情,但什么也没发生。

page1_page.prototype.image_3fzrc_onfocus = function()
{
    imgspring= caph.wui.widget._Component.getWidgetById("image_3fzrc");
    imgspring.setOpacity(0.5);
};

您要做的是:

$(document).ready(function(){
    $.caph.focus.activate(function(nearestFocusableFinderProvider, controllerProvider) {
        controllerProvider.onFocused(function(event, originalEvent) {
            $(event.currentTarget).css({
                opacity: 0.5
                });
            });
    }); 
});

但是,如果你有比图像更多的元素,你可以设置这样的条件,不影响任何元素聚焦,只影响图像:

$(document).ready(function(){
        $.caph.focus.activate(function(nearestFocusableFinderProvider, controllerProvider) {
            controllerProvider.onFocused(function(event, originalEvent) {
                //CONDITION: Just affect to elements with class 'image'
                if($(event.currentTarget).attr("class")=== 'image'){
                    $(event.currentTarget).css({
                         opacity: 0.5
                       });
                }
                });
        }); 
    });