1 #ifndef DALI_KEY_EVENT_H
2 #define DALI_KEY_EVENT_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <cstdint> // int32_t
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/object/base-handle.h>
28 #include <dali/public-api/events/device.h>
33 namespace Internal DALI_INTERNAL
39 * @addtogroup dali_core_events
44 * @brief The key event class is used to store a key press.
46 * It facilitates processing of these key presses and passing to other
47 * libraries like Toolkit. The keyString is the actual character you
48 * might want to display while the key name is just a descriptive
49 * name. There is a key modifier which relates to keys like alt,
50 * shift and control functions are supplied to check if they have been
53 * Currently KeyEvent is also being used to relay messages from the
54 * IMF(Input Method Framework) keyboard to the internal core. In future IMF may communicate via its own
58 class DALI_CORE_API KeyEvent : public BaseHandle
66 * @brief Enumeration for specifying the state of the key event.
71 DOWN, ///< Key down @SINCE_1_9.27
72 UP, ///< Key up @SINCE_1_9.27
76 * @brief An uninitialized KeyEvent instance.
78 * Calling member functions with an uninitialized KeyEvent handle is not allowed.
84 * @brief Copy constructor.
86 * @param[in] rhs A reference to the copied handle
88 KeyEvent( const KeyEvent& rhs );
91 * @brief Move constructor.
94 * @param[in] rhs A reference to the moved handle
96 KeyEvent( KeyEvent&& rhs );
99 * @brief Copy assignment operator.
101 * @param[in] rhs A reference to the copied handle
102 * @return A reference to this
104 KeyEvent& operator=( const KeyEvent& rhs );
107 * @brief Move assignment operator.
110 * @param[in] rhs A reference to the moved handle
111 * @return A reference to this
113 KeyEvent& operator=( KeyEvent&& rhs );
122 * @brief Checks to see if Shift key modifier has been supplied.
125 * @return True if shift modifier
127 bool IsShiftModifier() const;
130 * @brief Checks to see if Ctrl (control) key modifier has been supplied.
133 * @return True if ctrl modifier
135 bool IsCtrlModifier() const;
138 * @brief Checks to see if Alt key modifier has been supplied.
141 * @return True if alt modifier
143 bool IsAltModifier() const;
146 * @brief Get the key compose string.
149 * @return The compose string
151 const std::string& GetCompose() const;
154 * @brief Get the device name the key event originated from.
157 * @return The device name
159 const std::string& GetDeviceName() const;
162 * @brief Get the device class the key event originated from.
164 * The device class type is classification type of the input device of event received
166 * @return The type of the device class
168 Device::Class::Type GetDeviceClass() const;
171 * @brief Get the device subclass the key event originated from.
173 * The device subclass type is subclassification type of the input device of event received.
175 * @return The type of the device subclass
177 Device::Subclass::Type GetDeviceSubclass() const;
180 * @brief Get the name given to the key pressed or command from the IMF
183 * @return The name given to the key pressed.
185 const std::string& GetKeyName() const;
188 * @brief Get the actual string of input characters that should be used for input editors.
191 * @return The actual string of input characters
193 const std::string& GetKeyString() const;
196 * @brief Gets the logical key string.
198 * For example, when the user presses 'shift' key and '1' key together, the logical key is "exclamation".
199 * Plus, the key name is "1", and the key string is "!".
202 * @return The logical key symbol
204 const std::string& GetLogicalKey() const;
207 * @brief Get the unique key code for the key pressed.
210 * @return The unique key code for the key pressed
212 * @remarks We recommend not to use this key code value directly because its meaning
213 * might be changed in the future. Currently, it means a platform-specific key code.
214 * You need to use IsKey() to know what a key event means instead of direct comparison
217 int32_t GetKeyCode() const;
220 * @brief Return the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed.
223 * @return The key modifier
225 int32_t GetKeyModifier() const;
228 * @brief Get the time (in ms) that the key event occurred.
231 * @return The time (in ms)
233 unsigned long GetTime() const;
236 * @brief Get the state of the key event.
241 * @return The state of the key event
243 State GetState() const;
245 public: // Not intended for application developers
249 * @brief This constructor is used internally to Create an initialized KeyEvent handle.
252 * @param[in] keyEvent A pointer to a newly allocated Dali resource
254 explicit DALI_INTERNAL KeyEvent( Internal::KeyEvent* keyEvent );
263 #endif // DALI_KEY_EVENT_H