Class FtcChoiceMenu<T>

java.lang.Object
ftclib.driverio.FtcMenu
ftclib.driverio.FtcChoiceMenu<T>

public class FtcChoiceMenu<T> extends FtcMenu
This class implements a choice menu where a number of choices are presented to the user. The user can press the UP and DOWN button to navigate the different choices and press the ENTER button to select the choice. The user can also press the BACK button to cancel the menu and go back to the parent menu.
  • Field Details

    • choiceItems

      private final ArrayList<FtcChoiceMenu<T>.ChoiceItem> choiceItems
    • currChoice

      private int currChoice
    • firstDisplayedChoice

      private int firstDisplayedChoice
    • numDashboardLines

      private final int numDashboardLines
  • Constructor Details

    • FtcChoiceMenu

      public FtcChoiceMenu(String menuTitle, FtcMenu parent, FtcMenu.MenuButtons menuButtons)
      Constructor: Creates an instance of the object.
      Parameters:
      menuTitle - specifies the title of the menu. The title will be displayed as the first line in the menu.
      parent - specifies the parent menu to go back to if the BACK button is pressed. If this is the root menu, it can be set to null.
      menuButtons - specifies the object that implements the MenuButtons interface.
    • FtcChoiceMenu

      public FtcChoiceMenu(String menuTitle, FtcMenu parent)
      Constructor: Creates an instance of the object.
      Parameters:
      menuTitle - specifies the title of the menu. The title will be displayed as the first line in the menu.
      parent - specifies the parent menu to go back to if the BACK button is pressed. If this is the root menu, it can be set to null.
  • Method Details

    • addChoice

      public void addChoice(String choiceText, T choiceObject, boolean defChoice, FtcMenu childMenu)
      This method adds a choice to the menu. The choices will be displayed in the order of them being added.
      Parameters:
      choiceText - specifies the choice text that will be displayed on the dashboard.
      choiceObject - specifies the object to be returned if the choice is selected.
      defChoice - specifies true to set it the default choice, false otherwise.
      childMenu - specifies the next menu to go to when this choice is selected. If this is the last menu (a leaf node in the tree), it can be set to null.
    • addChoice

      public void addChoice(String choiceText, T choiceObj, boolean defChoice)
      This method adds a choice to the menu. The choices will be displayed in the order of them being added.
      Parameters:
      choiceText - specifies the choice text that will be displayed on the dashboard.
      choiceObj - specifies the object to be returned if the choice is selected.
      defChoice - specifies true to set it the default choice, false otherwise.
    • getCurrentChoice

      private FtcChoiceMenu<T>.ChoiceItem getCurrentChoice()
      This method returns the current selected choice item. Every menu has a current choice even if the menu hasn't been displayed and the user hasn't picked a choice. In that case, the current choice is the default selection of the menu which is the first choice in the menu. If the menu is empty, the current choice is null.
      Returns:
      current selected choice, null if menu is empty.
    • getCurrentChoiceText

      public String getCurrentChoiceText()
      This method returns the text of the current choice. Every menu has a current choice even if the menu hasn't been displayed and the user hasn't picked a choice. In that case, the current choice is the default selection of the menu which is the first choice in the menu. If the menu is empty, the current choice is null.
      Returns:
      current selected choice text, null if menu is empty.
    • getCurrentChoiceObject

      public T getCurrentChoiceObject()
      This method returns the object of the current choice. Every menu has a current choice even if the menu hasn't been displayed and the user hasn't picked a choice. In that case, the current choice is the default selection of the menu which is the first choice in the menu. If the menu is empty, the current choice is null.
      Returns:
      current choice object, null if menu is empty.
    • getChildMenu

      public FtcMenu getChildMenu()
      This method returns the child menu of the current choice.
      Specified by:
      getChildMenu in class FtcMenu
      Returns:
      child menu of the current choice.
    • displayMenu

      public void displayMenu()
      This method displays the menu on the dashboard with the current selection highlighted. The number of choices in the menu may exceed the total number of lines on the dashboard. In that case, it will only display all the choices that will fit on the dashboard. If the user navigates to a choice outside of the dashboard display, the choices will scroll up or down to bring the new selection into the dashboard.
      Specified by:
      displayMenu in class FtcMenu