Roku : Update RowList content without changing current focus item












1















Is there a way to update or append items to RowList content while keeping focus on the current selected/highlighted row item ?



Each row in the rowList is an independent list that is loaded asynchronously. The rowList is updated via an observeField method (Fig 1). The problem is that when the new content is added to the rowlist, the focus resets back to the first item in the first row. I want to keep the focus on whatever row item the user has navigated to while the rest of the rows are loading asynchronously.



I think the problem might be that I set the RowList.content to a new updated masterList each time (Fig 2).



I change the code to append a new row item, it also causes the focus to reset to the first row.




Fig 1.) m.ApiMixedListTask.observeField("responseObject", "onMixedListResponse")

Fig 2.)
function onMixedListResponse()
masterList.push(newRowItems)

m.top.gridContent = masterList
end function


Fig 3.) RowList: https://sdkdocs.roku.com/display/sdkdoc/RowList



  <RowList
id="RowList"
focusBitmapUri="pkg:/images/focus_grid.9.png"
translation="[-60, 372]"
itemSize="[1327, 218]"
numRows="3"
itemSpacing="[13, 0]"
focusXOffset="[147]"
rowFocusAnimationStyle="fixedFocusWrap"
rowItemSize="[[262, 147]]"
rowItemSpacing="[[16.5, 3]]"
showRowLabel="true"
showRowCounter="true"
rowLabelOffset="[[147, 20]]"
/>


Although this would make for a bad user experience, if keeping focus is not possible , I might just have to block user interaction while the content loads.










share|improve this question





























    1















    Is there a way to update or append items to RowList content while keeping focus on the current selected/highlighted row item ?



    Each row in the rowList is an independent list that is loaded asynchronously. The rowList is updated via an observeField method (Fig 1). The problem is that when the new content is added to the rowlist, the focus resets back to the first item in the first row. I want to keep the focus on whatever row item the user has navigated to while the rest of the rows are loading asynchronously.



    I think the problem might be that I set the RowList.content to a new updated masterList each time (Fig 2).



    I change the code to append a new row item, it also causes the focus to reset to the first row.




    Fig 1.) m.ApiMixedListTask.observeField("responseObject", "onMixedListResponse")

    Fig 2.)
    function onMixedListResponse()
    masterList.push(newRowItems)

    m.top.gridContent = masterList
    end function


    Fig 3.) RowList: https://sdkdocs.roku.com/display/sdkdoc/RowList



      <RowList
    id="RowList"
    focusBitmapUri="pkg:/images/focus_grid.9.png"
    translation="[-60, 372]"
    itemSize="[1327, 218]"
    numRows="3"
    itemSpacing="[13, 0]"
    focusXOffset="[147]"
    rowFocusAnimationStyle="fixedFocusWrap"
    rowItemSize="[[262, 147]]"
    rowItemSpacing="[[16.5, 3]]"
    showRowLabel="true"
    showRowCounter="true"
    rowLabelOffset="[[147, 20]]"
    />


    Although this would make for a bad user experience, if keeping focus is not possible , I might just have to block user interaction while the content loads.










    share|improve this question



























      1












      1








      1








      Is there a way to update or append items to RowList content while keeping focus on the current selected/highlighted row item ?



      Each row in the rowList is an independent list that is loaded asynchronously. The rowList is updated via an observeField method (Fig 1). The problem is that when the new content is added to the rowlist, the focus resets back to the first item in the first row. I want to keep the focus on whatever row item the user has navigated to while the rest of the rows are loading asynchronously.



      I think the problem might be that I set the RowList.content to a new updated masterList each time (Fig 2).



      I change the code to append a new row item, it also causes the focus to reset to the first row.




      Fig 1.) m.ApiMixedListTask.observeField("responseObject", "onMixedListResponse")

      Fig 2.)
      function onMixedListResponse()
      masterList.push(newRowItems)

      m.top.gridContent = masterList
      end function


      Fig 3.) RowList: https://sdkdocs.roku.com/display/sdkdoc/RowList



        <RowList
      id="RowList"
      focusBitmapUri="pkg:/images/focus_grid.9.png"
      translation="[-60, 372]"
      itemSize="[1327, 218]"
      numRows="3"
      itemSpacing="[13, 0]"
      focusXOffset="[147]"
      rowFocusAnimationStyle="fixedFocusWrap"
      rowItemSize="[[262, 147]]"
      rowItemSpacing="[[16.5, 3]]"
      showRowLabel="true"
      showRowCounter="true"
      rowLabelOffset="[[147, 20]]"
      />


      Although this would make for a bad user experience, if keeping focus is not possible , I might just have to block user interaction while the content loads.










      share|improve this question
















      Is there a way to update or append items to RowList content while keeping focus on the current selected/highlighted row item ?



      Each row in the rowList is an independent list that is loaded asynchronously. The rowList is updated via an observeField method (Fig 1). The problem is that when the new content is added to the rowlist, the focus resets back to the first item in the first row. I want to keep the focus on whatever row item the user has navigated to while the rest of the rows are loading asynchronously.



      I think the problem might be that I set the RowList.content to a new updated masterList each time (Fig 2).



      I change the code to append a new row item, it also causes the focus to reset to the first row.




      Fig 1.) m.ApiMixedListTask.observeField("responseObject", "onMixedListResponse")

      Fig 2.)
      function onMixedListResponse()
      masterList.push(newRowItems)

      m.top.gridContent = masterList
      end function


      Fig 3.) RowList: https://sdkdocs.roku.com/display/sdkdoc/RowList



        <RowList
      id="RowList"
      focusBitmapUri="pkg:/images/focus_grid.9.png"
      translation="[-60, 372]"
      itemSize="[1327, 218]"
      numRows="3"
      itemSpacing="[13, 0]"
      focusXOffset="[147]"
      rowFocusAnimationStyle="fixedFocusWrap"
      rowItemSize="[[262, 147]]"
      rowItemSpacing="[[16.5, 3]]"
      showRowLabel="true"
      showRowCounter="true"
      rowLabelOffset="[[147, 20]]"
      />


      Although this would make for a bad user experience, if keeping focus is not possible , I might just have to block user interaction while the content loads.







      roku brightscript scenegraph






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 30 '18 at 19:42







      Fabii

















      asked May 30 '18 at 17:17









      FabiiFabii

      1,79683777




      1,79683777
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You are right! You are having issues because You set the RowList.content to a new updated masterList each time.
          I'm not sure if this code will work if you just copy/paste it into your project but it will give you the example of what you could do:



           for each item in m.ApiMixedListTask.newRowItems
          content = createObject("RoSGNode", "ContentNode")
          for each key in m.ApiMixedListTask.newRowItems[item]
          content[key] = m.ApiMixedListTask.newRowItems[item][key]
          end for

          m.RowList.content.getChild(0).appendChild(content)
          end for





          share|improve this answer
























          • I'll give it a try, and let you know how it works out.

            – Fabii
            May 31 '18 at 14:05











          • Thank I have to tweak it a bit, but the general idea worked. Thanks again.

            – Fabii
            May 31 '18 at 15:12











          • Nice! Glad I could help. :-)

            – U.Mitic
            May 31 '18 at 15:13



















          0














          You need to know a weird behaviour of Roku. If you get new rows content from a function, some of the cells will be invalid even if you create as it should be.



          For eaxample, this code will not work as expected:



          function MapMatchList(data, countInARow = 4)
          rowListContent = createObject("RoSGNode","ContentNode")
          if data = invalid then return rowListContent
          list = data.List
          if list = invalid then return rowListContent

          row = createObject("RoSGNode","ContentNode")
          rowListContent.appendChild(row)
          counter = 1
          for i = 0 to list.count() - 1
          if counter > countInARow
          counter = 1
          row = createObject("RoSGNode","ContentNode")
          rowListContent.appendChild(row)
          end if
          match = MapMatch(list[i])
          if match <> invalid
          row.appendChild(match)
          end if
          counter = counter + 1
          end for
          return rowListContent
          end Function


          When you call function, some of cells turn to invalid



          rows = MapMatchList(m.top.MoreData)
          for i = 0 to rows.getChildCount() - 1
          m.rowlist.content.appendChild(rows.getChild(i))
          end for


          You need to change some of code:



          function MapMatchList(data, countInARow = 4, rowListContent = invalid)
          if rowListContent = invalid then rowListContent = createObject("RoSGNode","ContentNode")


          Finally you can call it:



          MapMatchList(m.top.MoreData, 4, m.rowlist.content) 





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50610272%2froku-update-rowlist-content-without-changing-current-focus-item%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You are right! You are having issues because You set the RowList.content to a new updated masterList each time.
            I'm not sure if this code will work if you just copy/paste it into your project but it will give you the example of what you could do:



             for each item in m.ApiMixedListTask.newRowItems
            content = createObject("RoSGNode", "ContentNode")
            for each key in m.ApiMixedListTask.newRowItems[item]
            content[key] = m.ApiMixedListTask.newRowItems[item][key]
            end for

            m.RowList.content.getChild(0).appendChild(content)
            end for





            share|improve this answer
























            • I'll give it a try, and let you know how it works out.

              – Fabii
              May 31 '18 at 14:05











            • Thank I have to tweak it a bit, but the general idea worked. Thanks again.

              – Fabii
              May 31 '18 at 15:12











            • Nice! Glad I could help. :-)

              – U.Mitic
              May 31 '18 at 15:13
















            0














            You are right! You are having issues because You set the RowList.content to a new updated masterList each time.
            I'm not sure if this code will work if you just copy/paste it into your project but it will give you the example of what you could do:



             for each item in m.ApiMixedListTask.newRowItems
            content = createObject("RoSGNode", "ContentNode")
            for each key in m.ApiMixedListTask.newRowItems[item]
            content[key] = m.ApiMixedListTask.newRowItems[item][key]
            end for

            m.RowList.content.getChild(0).appendChild(content)
            end for





            share|improve this answer
























            • I'll give it a try, and let you know how it works out.

              – Fabii
              May 31 '18 at 14:05











            • Thank I have to tweak it a bit, but the general idea worked. Thanks again.

              – Fabii
              May 31 '18 at 15:12











            • Nice! Glad I could help. :-)

              – U.Mitic
              May 31 '18 at 15:13














            0












            0








            0







            You are right! You are having issues because You set the RowList.content to a new updated masterList each time.
            I'm not sure if this code will work if you just copy/paste it into your project but it will give you the example of what you could do:



             for each item in m.ApiMixedListTask.newRowItems
            content = createObject("RoSGNode", "ContentNode")
            for each key in m.ApiMixedListTask.newRowItems[item]
            content[key] = m.ApiMixedListTask.newRowItems[item][key]
            end for

            m.RowList.content.getChild(0).appendChild(content)
            end for





            share|improve this answer













            You are right! You are having issues because You set the RowList.content to a new updated masterList each time.
            I'm not sure if this code will work if you just copy/paste it into your project but it will give you the example of what you could do:



             for each item in m.ApiMixedListTask.newRowItems
            content = createObject("RoSGNode", "ContentNode")
            for each key in m.ApiMixedListTask.newRowItems[item]
            content[key] = m.ApiMixedListTask.newRowItems[item][key]
            end for

            m.RowList.content.getChild(0).appendChild(content)
            end for






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 30 '18 at 21:39









            U.MiticU.Mitic

            3891312




            3891312













            • I'll give it a try, and let you know how it works out.

              – Fabii
              May 31 '18 at 14:05











            • Thank I have to tweak it a bit, but the general idea worked. Thanks again.

              – Fabii
              May 31 '18 at 15:12











            • Nice! Glad I could help. :-)

              – U.Mitic
              May 31 '18 at 15:13



















            • I'll give it a try, and let you know how it works out.

              – Fabii
              May 31 '18 at 14:05











            • Thank I have to tweak it a bit, but the general idea worked. Thanks again.

              – Fabii
              May 31 '18 at 15:12











            • Nice! Glad I could help. :-)

              – U.Mitic
              May 31 '18 at 15:13

















            I'll give it a try, and let you know how it works out.

            – Fabii
            May 31 '18 at 14:05





            I'll give it a try, and let you know how it works out.

            – Fabii
            May 31 '18 at 14:05













            Thank I have to tweak it a bit, but the general idea worked. Thanks again.

            – Fabii
            May 31 '18 at 15:12





            Thank I have to tweak it a bit, but the general idea worked. Thanks again.

            – Fabii
            May 31 '18 at 15:12













            Nice! Glad I could help. :-)

            – U.Mitic
            May 31 '18 at 15:13





            Nice! Glad I could help. :-)

            – U.Mitic
            May 31 '18 at 15:13













            0














            You need to know a weird behaviour of Roku. If you get new rows content from a function, some of the cells will be invalid even if you create as it should be.



            For eaxample, this code will not work as expected:



            function MapMatchList(data, countInARow = 4)
            rowListContent = createObject("RoSGNode","ContentNode")
            if data = invalid then return rowListContent
            list = data.List
            if list = invalid then return rowListContent

            row = createObject("RoSGNode","ContentNode")
            rowListContent.appendChild(row)
            counter = 1
            for i = 0 to list.count() - 1
            if counter > countInARow
            counter = 1
            row = createObject("RoSGNode","ContentNode")
            rowListContent.appendChild(row)
            end if
            match = MapMatch(list[i])
            if match <> invalid
            row.appendChild(match)
            end if
            counter = counter + 1
            end for
            return rowListContent
            end Function


            When you call function, some of cells turn to invalid



            rows = MapMatchList(m.top.MoreData)
            for i = 0 to rows.getChildCount() - 1
            m.rowlist.content.appendChild(rows.getChild(i))
            end for


            You need to change some of code:



            function MapMatchList(data, countInARow = 4, rowListContent = invalid)
            if rowListContent = invalid then rowListContent = createObject("RoSGNode","ContentNode")


            Finally you can call it:



            MapMatchList(m.top.MoreData, 4, m.rowlist.content) 





            share|improve this answer




























              0














              You need to know a weird behaviour of Roku. If you get new rows content from a function, some of the cells will be invalid even if you create as it should be.



              For eaxample, this code will not work as expected:



              function MapMatchList(data, countInARow = 4)
              rowListContent = createObject("RoSGNode","ContentNode")
              if data = invalid then return rowListContent
              list = data.List
              if list = invalid then return rowListContent

              row = createObject("RoSGNode","ContentNode")
              rowListContent.appendChild(row)
              counter = 1
              for i = 0 to list.count() - 1
              if counter > countInARow
              counter = 1
              row = createObject("RoSGNode","ContentNode")
              rowListContent.appendChild(row)
              end if
              match = MapMatch(list[i])
              if match <> invalid
              row.appendChild(match)
              end if
              counter = counter + 1
              end for
              return rowListContent
              end Function


              When you call function, some of cells turn to invalid



              rows = MapMatchList(m.top.MoreData)
              for i = 0 to rows.getChildCount() - 1
              m.rowlist.content.appendChild(rows.getChild(i))
              end for


              You need to change some of code:



              function MapMatchList(data, countInARow = 4, rowListContent = invalid)
              if rowListContent = invalid then rowListContent = createObject("RoSGNode","ContentNode")


              Finally you can call it:



              MapMatchList(m.top.MoreData, 4, m.rowlist.content) 





              share|improve this answer


























                0












                0








                0







                You need to know a weird behaviour of Roku. If you get new rows content from a function, some of the cells will be invalid even if you create as it should be.



                For eaxample, this code will not work as expected:



                function MapMatchList(data, countInARow = 4)
                rowListContent = createObject("RoSGNode","ContentNode")
                if data = invalid then return rowListContent
                list = data.List
                if list = invalid then return rowListContent

                row = createObject("RoSGNode","ContentNode")
                rowListContent.appendChild(row)
                counter = 1
                for i = 0 to list.count() - 1
                if counter > countInARow
                counter = 1
                row = createObject("RoSGNode","ContentNode")
                rowListContent.appendChild(row)
                end if
                match = MapMatch(list[i])
                if match <> invalid
                row.appendChild(match)
                end if
                counter = counter + 1
                end for
                return rowListContent
                end Function


                When you call function, some of cells turn to invalid



                rows = MapMatchList(m.top.MoreData)
                for i = 0 to rows.getChildCount() - 1
                m.rowlist.content.appendChild(rows.getChild(i))
                end for


                You need to change some of code:



                function MapMatchList(data, countInARow = 4, rowListContent = invalid)
                if rowListContent = invalid then rowListContent = createObject("RoSGNode","ContentNode")


                Finally you can call it:



                MapMatchList(m.top.MoreData, 4, m.rowlist.content) 





                share|improve this answer













                You need to know a weird behaviour of Roku. If you get new rows content from a function, some of the cells will be invalid even if you create as it should be.



                For eaxample, this code will not work as expected:



                function MapMatchList(data, countInARow = 4)
                rowListContent = createObject("RoSGNode","ContentNode")
                if data = invalid then return rowListContent
                list = data.List
                if list = invalid then return rowListContent

                row = createObject("RoSGNode","ContentNode")
                rowListContent.appendChild(row)
                counter = 1
                for i = 0 to list.count() - 1
                if counter > countInARow
                counter = 1
                row = createObject("RoSGNode","ContentNode")
                rowListContent.appendChild(row)
                end if
                match = MapMatch(list[i])
                if match <> invalid
                row.appendChild(match)
                end if
                counter = counter + 1
                end for
                return rowListContent
                end Function


                When you call function, some of cells turn to invalid



                rows = MapMatchList(m.top.MoreData)
                for i = 0 to rows.getChildCount() - 1
                m.rowlist.content.appendChild(rows.getChild(i))
                end for


                You need to change some of code:



                function MapMatchList(data, countInARow = 4, rowListContent = invalid)
                if rowListContent = invalid then rowListContent = createObject("RoSGNode","ContentNode")


                Finally you can call it:



                MapMatchList(m.top.MoreData, 4, m.rowlist.content) 






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 7:03









                Fatih ÇelikFatih Çelik

                208312




                208312






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50610272%2froku-update-rowlist-content-without-changing-current-focus-item%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    To store a contact into the json file from server.js file using a class in NodeJS

                    Redirect URL with Chrome Remote Debugging Android Devices

                    Dieringhausen