Redirect to Home page After Clicked Save button using bright script?

橙三吉。 提交于 2019-12-23 07:12:54

问题


  1. I have created Login Screen and setting URL Screen in bright script with the credential username, password in Login screen and setting URL in setting URL Screen with two buttons save and setting.

Here simply my Login Screen:

  • Login Screen

    '''''''''''''''''''''''''''''''''''''''''''''''''''

    UserName: TextBox1

    Password: TextBox2

    Save Setting

    '''''''''''''''''''''''''''''''''''''''''''''''''''

I Click the Setting Button open setting URL Screen it's here:

  • URL Screen

    ''''''''''''''''''''''''''''''''''''''

    URL: TextBox3

    Save

    ''''''''''''''''''''''''''''''''''''''

I write setting URL in setting URL Screen and after that, I click Save Button. now After saving the setting URL, I want to navigate back to the Login Screen Again. I store all three credential in roRegistrySection.It's a store successfully. But navigation between the login screen and setting URL screen is not working properly. When I click on save Button it open home screen. anyone know how to navigate between two screens.

Expected result: as per below steps.

  1. First, I click on setting button to enter the URL in a textbox. After clicking on the save button again navigate back to the Login Screen.

  2. In Login Screen I have two textboxes. After entering the user name and password, I click on the save button then redirect to the home page with three value store in roRegistrySection.

Anyone know the Issue.


回答1:


check this getting-started-with-brightscript-screen-navigation

Implementing a Simple Navigation Menu The screenshot below shows a landing page typical of many Roku channels. The list screen component is a common way to implement simple menus that drive the navigation through channel content. Each list item can represent a video genre, a music style, a group of settings, or any other content category that you want to group in your channel. In a typical channel, when a list item is selected, the channel navigates to a new screen. In our example, the list screen allows the user to browse the breakfast and lunch menus at a hypothetical diner. Selecting one of the items brings up a detailed list of offerings for that particular meal category.

The key to navigating to a new screen when a list item is selected is to handle the list screen’s isListItemSelected event. The index returned by msg.GetIndex() contains the zero-based index of the selected list item. Your channel can map each list item index to a unique screen and navigate to that screen in response to the isListItemSelected event. There are a couple of ways to accomplish this. The simplest is to just use an if statement approach in the calling screen’s event loop that tests the selected index and calls the right function:

while (true)
    msg = wait(0, port)
    if (type(msg) = "roListScreenEvent")
      if (msg.isListItemSelected())
        index = msg.GetIndex()
        if (index = 0)
          ShowBreakfastMenu()
        else if (index = 1)
          ShowLunchMenu()
          …
        endif
      endif
    endif
end while

Another more complex, but cleaner, way to do this is to create an array of function references.

menuFunctions = [ShowBreakfastMenu, ShowLunchMenu,…]
while (true)
    msg = wait(0, port)
    if (type(msg) = "roListScreenEvent")
      if (msg.isListItemSelected())
        menuFunctions[msg.GetIndex()]() ‘Call function based on index
      endif
    endif
end while

The key to understanding how this code works lies in the BrightScript function reference concept. A function reference is just the name of a given function. Function references can be assigned to variables, used as array elements, and even passed to other functions. The function that corresponds to a function reference can be called by using the function call operator “()”. Here are some examples of calling a function called doSomething by reference:

Function doSomething() as void
    ...
End Function
doSomethingReference = doSomething
‘Call doSomething by reference
doSomethingReference()
references = [doSomething, …] 

‘We can also put function references in an array references0 ‘Call doSomething through the array element function reference With this in mind, let’s go back to the second approach to implementing the menu in the list view screen. The array menuFunctions contains the name of each of the channel’s screen creation functions. These are in the same order as the list items to which they correspond in the associated list screen. Then, when the isListItemSelected event is handled in the list screen’s event loop, we grab the corresponding function name from the menuFunctions array. The function is then called by reference using the “()” operator on the correct array element:

menuFunctions[msg.GetIndex()]() ‘Call function based on index In the sample channel we use the function reference approach. To see what the menu items actually do, click the Breakfast menu item and you’ll see the detailed breakfast menu rendered in a simple poster screen:

Clicking the Lunch menu item displays the detailed lunch menu, which is implemented using a grid screen:

Deeper Navigation So far we’ve looked at how to use a list screen to build simple category navigation into a channel. Moving from screens like the poster or grid screens above to other screens in your channel is just as easy. Simply handle the isListItemSelected event in the screen’s event loop to detect when an item is selected and respond appropriately.

In the sample channel, you can click on any of the items in the breakfast menu poster screen to display a details screen with more information about the selected item. A sample of this screen (also called a “springboard” screen) is shown below:

The two buttons at the right of this screen demonstrate another BrightScript navigation technique. When one of these buttons is selected, the details screen receives an isButtonPressed event. The message sent with the event contains the index of the selected button. As with list, poster, and grid screen item indexes, this button index can be used to control what the channel does in response to the button press, including navigating to new screens, opening dialogs, and other actions.

while (true)
    msg = wait(0, port)
    if (type(msg) = "roSpringboardScreenEvent")
      if (msg.isButtonPressed())
        buttonIndex = msg.GetIndex()
        'Open a new screen corresponding to the button index
        …
      endif
  endif
end while

To try and minimize the size of the sample channel download, only the breakfast and lunch list screen items open poster or grid screens. Furthermore, only the breakfast menu poster screen items can be clicked to open details screens. You could easily use these two categories as a guide to complete the channel on your own. Or you can just use the code as is to get started navigating within your own channels. Happy coding!



来源:https://stackoverflow.com/questions/56753908/redirect-to-home-page-after-clicked-save-button-using-bright-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!