Samsung TV SDK中的CAPH API小部件

问题描述 投票:0回答:1

我做了一个非常简单的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);
};
javascript samsung-smart-tv
1个回答
0
投票

你要做的是:

$(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
                       });
                }
                });
        }); 
    });
© www.soinside.com 2019 - 2024. All rights reserved.