1 #ifndef __DALI_KEY_EVENT_H__
2 #define __DALI_KEY_EVENT_H__
5 * Copyright (c) 2017 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.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/events/device.h>
31 * @addtogroup dali_core_events
36 * @brief The key event structure is used to store a key press.
38 * It facilitates processing of these key presses and passing to other
39 * libraries like Toolkit. The keyString is the actual character you
40 * might want to display while the key name is just a descriptive
41 * name. There is a key modifier which relates to keys like alt,
42 * shift and control functions are supplied to check if they have been
45 * Currently KeyEvent is also being used to relay messages from the
46 * IMF(Input Method Framework) keyboard to the internal core. In future IMF may communicate via its own
50 struct DALI_IMPORT_API KeyEvent
55 * @brief Enumeration for specifying the state of the key event.
60 Down, ///< Key down @SINCE_1_0.0
61 Up, ///< Key up @SINCE_1_0.0
66 * @brief Default constructor.
75 * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed
76 * @param[in] keyString A string of input characters or key pressed
77 * @param[in] keyCode The unique key code for the key pressed
78 * @param[in] keyModifier The key modifier for special keys like shift and alt
79 * @param[in] timeStamp The time (in ms) that the key event occurred
80 * @param[in] keyState The state of the key event
82 KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier, unsigned long timeStamp, const State& keyState);
85 * @brief Copy constructor.
87 * @param[in] rhs A reference to the copied handle
89 KeyEvent( const KeyEvent& rhs );
92 * @brief Assignment operator.
94 * @param[in] rhs A reference to the copied handle
95 * @return A reference to this
97 KeyEvent& operator=( const KeyEvent& rhs );
106 * @brief Checks to see if Shift key modifier has been supplied.
109 * @return True if shift modifier
111 bool IsShiftModifier() const;
114 * @brief Checks to see if Ctrl (control) key modifier has been supplied.
117 * @return True if ctrl modifier
119 bool IsCtrlModifier() const;
122 * @brief Checks to see if Alt key modifier has been supplied.
125 * @return True if alt modifier
127 bool IsAltModifier() const;
130 * @brief Get the device name the key event originated from.
133 * @return The device name
135 std::string GetDeviceName() const;
138 * @brief Get the device class the key event originated from.
140 * The device class type is classification type of the input device of event received
142 * @return The type of the device class
144 Device::Class::Type GetDeviceClass() const;
147 * @brief Get the device subclass the key event originated from.
149 * The device subclass type is subclassification type of the input device of event received.
151 * @return The type of the device subclass
153 Device::Subclass::Type GetDeviceSubclass() const;
158 * @brief Name given to the key pressed.
160 std::string keyPressedName;
163 * @brief The actual string returned that should be used for input editors.
165 std::string keyPressed;
168 * @brief Keycode for the key pressed.
170 * @remarks We recommend not to use this key code value
171 * directly because its meaning might be changed in the future. Currently, it means a
172 * platform-specific key code. You need to use IsKey() to know what a key event means
173 * instead of direct comparison of key code value.
178 * @brief special keys like shift, alt and control which modify the next key pressed.
183 * @brief The time (in ms) that the key event occurred.
188 * @brief State of the key event.
201 #endif // __DALI_KEY_EVENT_H__