AuboCaps  0.4.1
keyboard_text_input.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_KEYBOARD_TEXT_INPUT_H
2 #define AUBO_SCOPE_KEYBOARD_TEXT_INPUT_H
3 
4 #include <memory>
5 #include <functional>
6 
9 
10 class QWidget;
11 
12 namespace arcs {
13 namespace aubo_scope {
14 
15 ARCS_CLASS_FORWARD(KeyboardTextInput);
16 
17 /**
18  * Interface representing the virtual keyboard used for configuring it and
19  * requesting it to be displayed in PolyScope.
20  */
22 {
23 public:
26  virtual ~KeyboardTextInput();
27 
28  /**
29  * <p>
30  * Sets an input validator for the virtual keyboard. This validator will be
31  * used to validate the input entered by the user. Some standard validators
32  * are available in
33  * {@link domain.userinteraction.inputvalidation.InputValidationFactory}.
34  * </p>
35  *
36  * <p>
37  * Specifying an input validator is recommended, but optional.
38  * </p>
39  *
40  * In case {@link InputValidator#isValid(Object)} (in this case parameter is
41  * {@link String}) returns <code>false</code>, the accept button on the
42  * virtual keyboard will be disabled and the error message from {@link
43  * InputValidator#getMessage(Object)} (parameter is {@link String}) will be
44  * shown.
45  *
46  * @param validator the validator to be used to validate keyboard user
47  * input.
48  * @return this KeyboardTextInput object.
49  * @throws NullPointerException in case the validator is <code>null</code>.
50  */
51  void setErrorValidator(
52  const std::shared_ptr<InputValidator<std::string>> &validator);
53 
54  /**
55  * Sets the text which will be displayed when the virtual keyboard is shown.
56  *
57  * @param initialText the initial text for the virtual keyboard.
58  * @return this KeyboardTextInput object.
59  */
60  virtual void setInitialValue(const std::string &initialText);
61 
62  /**
63  * This method requests the virtual standard keyboard to be shown.
64  *
65  * @param component the JTextField that will be used to define the screen
66  * position of the virtual keyboard. The component must be visible on the
67  * screen at the time of showing the keypad.
68  * @param callback the callback to be used when the user exits the keyboard
69  * by accepting or canceling the input.
70  * @throws NullPointerException in case any parameter is <code>null</code>.
71  */
72  void show(QWidget *component,
73  const std::function<void(bool, const std::string &)> &callback);
74 
75 private:
76  friend class DataSwitch;
78  void *d_{ nullptr };
79 };
80 } // namespace aubo_scope
81 } // namespace arcs
82 
83 #endif
ARCS_CLASS_FORWARD(GripForceCapability)
Interface representing the virtual keyboard used for configuring it and requesting it to be displayed...
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16