Package ftclib.driverio
Class FtcChoiceMenu<T>
java.lang.Object
ftclib.driverio.FtcMenu
ftclib.driverio.FtcChoiceMenu<T>
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
This class defines a choice item in a choice menu.Nested classes/interfaces inherited from class ftclib.driverio.FtcMenu
FtcMenu.MenuButtons
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ArrayList<FtcChoiceMenu<T>.ChoiceItem>
private int
private int
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionFtcChoiceMenu
(String menuTitle, FtcMenu parent) Constructor: Creates an instance of the object.FtcChoiceMenu
(String menuTitle, FtcMenu parent, FtcMenu.MenuButtons menuButtons) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method adds a choice to the menu.void
This method adds a choice to the menu.void
This method displays the menu on the dashboard with the current selection highlighted.This method returns the child menu of the current choice.private FtcChoiceMenu<T>.ChoiceItem
This method returns the current selected choice item.This method returns the object of the current choice.This method returns the text of the current choice.void
This method does nothing in Choice Menu.void
This method does nothing in Choice Menu.void
menuDown()
This method moves the current selection to the next choice in the menu.void
menuUp()
This method moves the current selection to the previous choice in the menu.Methods inherited from class ftclib.driverio.FtcMenu
getParentMenu, getTitle, runMenus, setRootMenu, walkMenuTree
-
Field Details
-
choiceItems
-
currChoice
private int currChoice -
firstDisplayedChoice
private int firstDisplayedChoice -
numDashboardLines
private final int numDashboardLines
-
-
Constructor Details
-
FtcChoiceMenu
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
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
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
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
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
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
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
This method returns the child menu of the current choice.- Specified by:
getChildMenu
in classFtcMenu
- 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 classFtcMenu
-