VR-Engage  2.2
Loading...
Searching...
No Matches
actionInputMenu.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file actionInputMenu.h
7//! \brief Defines a text input menu for VR-Engage
8//!
9//! This file contains the DtActionInputMenu class which provides text input
10//! functionality within the VR-Engage menu system. It allows users to enter
11//! and edit text with keyboard input, validate that input according to specific
12//! format requirements, and send the entered text as an action parameter when
13//! the input is completed.
14
15#pragma once
16
21
22#include <vrvCore/DtKeyState.h>
23
24#include <string>
25
26namespace makVrv
27{
28class DtDe;
29class DtQuadProxy;
30class DtTextProxy;
31class DtOverlayRenderer;
32class DtOsgChannel;
33} // namespace makVrv
34
35namespace makVre
36{
37//! \brief Menu subclass for text input functionality
38//!
39//! DtActionInputMenu provides a specialized menu for text input in VR-Engage.
40//! It captures keyboard input, displays the entered text, validates it according
41//! to format requirements, and sends the completed text as an action parameter
42//! when the user finalizes their input. This class is used for various text entry
43//! needs such as coordinates, radio frequencies, names, and other text-based inputs.
45{
46public:
47 //! \brief Constructor
48 //! \param mgr Reference to the menu manager
49 //!
50 //! Creates a new input menu associated with the specified menu manager.
51 //! The menu starts with empty input text and uses the default null validator
52 //! which accepts any input text as valid.
54
55 //! \brief Virtual destructor
56 //!
57 //! Ensures proper cleanup of derived input menu classes.
58 virtual ~DtActionInputMenu() override;
59
60 //! \brief Sets the current input text
61 //! \param input The text to set as the current input
62 //!
63 //! Updates the current input text and refreshes the visual display.
64 //! This can be used to preset the input field with existing text.
65 virtual void setInputText(const std::string& input);
66
67 //! \brief Gets the current input text
68 //! \return The current input text
69 //!
70 //! Retrieves the text currently entered in the input field.
71 virtual std::string inputText() const;
72
73 //! \brief Sets the input validator function
74 //! \param validator The validator delegate function to use
75 //!
76 //! Sets the function used to validate input text. The validator function
77 //! receives the current input text and returns true if it is valid according
78 //! to the expected format, or false if it is invalid.
79 virtual void setInputValidator(DtInputValidator validator);
80
81 //! \brief Gets the current input validator
82 //! \return The current input validator function
83 //!
84 //! Retrieves the validator function currently being used to validate input.
86
87 //! \brief Sets the action type for this input menu
88 //! \param actionType The action type identifier
89 //!
90 //! Sets the action type that will be sent when the user completes their input.
91 //! This identifier helps the receiving component determine how to handle the input.
92 //! The default action type is "InputMenuAccept".
93 virtual void setActionType(const std::string& actionType);
94
95 //! \brief Gets the current action type
96 //! \return The current action type identifier
97 //!
98 //! Retrieves the action type that will be sent when input is completed.
99 virtual std::string actionType() const;
100
101 //! \brief Sets the default string to use when input is empty
102 //! \param defaultString The default string to use
103 //!
104 //! Sets a default string that will be used if the user submits an empty input.
105 //! This allows for pre-defined values to be used when no specific input is provided.
106 virtual void setDefaultString(const std::string& defaultString);
107
108 //! \brief Gets the current default string
109 //! \return The current default string
110 //!
111 //! Retrieves the default string that will be used for empty input.
112 virtual std::string defaultString() const;
113
114 //! \brief Handles selection of the input menu
115 //! \param val Input value (typically 1.0 for full selection)
116 //!
117 //! Called when the input is completed by the user. This sends the entered text
118 //! (or default text if empty) as an action with the specified action type,
119 //! then returns to the parent menu or closes if no parent exists.
120 virtual void select(float val = 1) override;
121
122 //! \brief Default validator that accepts any input
123 //!
124 //! A static input validator that always returns true, accepting any input.
125 //! This is used as the default validator when no specific validation is needed.
127
128 //! \brief Sets the active state of the input menu
129 //! \param active True to activate the menu, false to deactivate
130 //! \param saveSelection Whether to save the current selection state
131 //! \param closeOnElementSelected Whether to close after selection (unused)
132 //!
133 //! Overrides DtMenu::setActive to reset the input text when the menu is activated
134 //! and display the default string hint if one is set.
135 virtual void setActive(bool active, bool saveSelection = false, bool closeOnElementSelected = false) override;
136
137 //! \brief Activates the input handling logic
138 //!
139 //! Overrides DtMenu::activateInputLogic to set up raw input handling
140 //! for keyboard input. This allows the menu to capture keyboard events
141 //! directly for text entry.
142 virtual void activateInputLogic() override;
143
144protected:
145 //! \brief Handles raw input data for text entry
146 //! \param inputData The input data event to process
147 //! \return True if the input was handled, false otherwise
148 //!
149 //! Processes keyboard input events for text entry. This method handles
150 //! special keys (backspace, enter, escape) and passes regular characters
151 //! to addCharacter for text building. It's registered as a raw input handler
152 //! when the menu is activated.
153 virtual bool handleInputData(const DtInputData& inputData);
154
155 //! \brief Adds a character to the input text
156 //! \param key The keyboard key type to add
157 //!
158 //! Converts a keyboard key code to a character and adds it to the input text
159 //! if the resulting string passes validation. Updates the visual display
160 //! after adding the character.
161 virtual void addCharacter(makVrv::DtKeyState::KeyType key);
162
163 //! \brief Removes the last character from the input text
164 //!
165 //! Removes the last character from the input text (backspace functionality).
166 //! If the input becomes empty, displays the default string hint if one is set.
167 //! Updates the visual display after removing the character.
168 virtual void removeCharacter();
169
170 //! \brief Sends the completed input text as an action
171 //!
172 //! Creates and queues a MenuActionMessage with the current action type and
173 //! the input text (or default text if input is empty) as the parameter.
174 //! This is called when the user completes their input by pressing Enter.
175 virtual void sendText();
176
177 //! \brief Current input text string
178 //!
179 //! Stores the text currently entered by the user.
180 std::string myInputString;
181
182 //! \brief Action type identifier for this input menu
183 //!
184 //! The action type that will be sent when the user completes their input.
185 //! Default is "InputMenuAccept".
186 std::string myActionType;
187
188 //! \brief Validator function for input validation
189 //!
190 //! Function delegate used to validate input text against format requirements.
192
193 //! \brief Menu element that displays the input text
194 //!
195 //! The menu element used to display the current input text to the user.
197
198 //! \brief Default string to use when input is empty
199 //!
200 //! String that will be used if the user submits an empty input.
201 //! Also displayed as a hint when the input field is empty.
202 std::string myDefaultString;
203};
204
205} // namespace makVre
Defines the core menu class for VR-Engage.
Defines the menu element classes for interactive menus.
Defines the menu management system for VR-Engage.
virtual ~DtActionInputMenu() override
Virtual destructor.
virtual void setActionType(const std::string &actionType)
Sets the action type for this input menu.
DtInputValidator myInputValidator
Validator function for input validation.
Definition actionInputMenu.h:191
std::string myActionType
Action type identifier for this input menu.
Definition actionInputMenu.h:186
virtual void setInputValidator(DtInputValidator validator)
Sets the input validator function.
std::string myDefaultString
Default string to use when input is empty.
Definition actionInputMenu.h:202
std::string myInputString
Current input text string.
Definition actionInputMenu.h:180
virtual void select(float val=1) override
Handles selection of the input menu.
virtual void addCharacter(makVrv::DtKeyState::KeyType key)
Adds a character to the input text.
virtual void setInputText(const std::string &input)
Sets the current input text.
virtual bool handleInputData(const DtInputData &inputData)
Handles raw input data for text entry.
virtual void setDefaultString(const std::string &defaultString)
Sets the default string to use when input is empty.
virtual std::string actionType() const
Gets the current action type.
virtual void setActive(bool active, bool saveSelection=false, bool closeOnElementSelected=false) override
Sets the active state of the input menu.
virtual std::string inputText() const
Gets the current input text.
virtual void removeCharacter()
Removes the last character from the input text.
DtMenuElement * myInputElement
Menu element that displays the input text.
Definition actionInputMenu.h:196
static DtInputValidator theNullInputValidator
Default validator that accepts any input.
Definition actionInputMenu.h:126
virtual void sendText()
Sends the completed input text as an action.
virtual DtInputValidator inputValidator() const
Gets the current input validator.
virtual std::string defaultString() const
Gets the current default string.
DtActionInputMenu(DtMenuManager &mgr)
Constructor.
virtual void activateInputLogic() override
Activates the input handling logic.
Menu element class for interactive menus.
Definition actionMenuElement.h:40
DtMenu(DtMenuManager &mgr)
Constructor.
Central manager for all menus in VR-Engage.
Definition actionMenuManager.h:111
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtDelegate< bool, const std::string & > DtInputValidator
Type definition for input validation delegate functions.
Definition actionMenuManager.h:51
Definition appLauncherComponent.h:28
Structure for transferring input data through the input system.
Definition inputData.h:89