-#ifndef __DALI_KEY_EVENT_H__
-#define __DALI_KEY_EVENT_H__
+#ifndef DALI_KEY_EVENT_H
+#define DALI_KEY_EVENT_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// EXTERNAL INCLUDES
+#include <cstdint> // int32_t
#include <string>
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/events/device.h>
+#include <dali/public-api/object/base-handle.h>
namespace Dali
{
+namespace Internal DALI_INTERNAL
+{
+class KeyEvent;
+}
+
/**
* @addtogroup dali_core_events
* @{
*/
/**
- * @brief The key event structure is used to store a key press.
+ * @brief The key event class is used to store a key press.
*
* It facilitates processing of these key presses and passing to other
* libraries like Toolkit. The keyString is the actual character you
* module.
* @SINCE_1_0.0
*/
-struct DALI_IMPORT_API KeyEvent
+class DALI_CORE_API KeyEvent : public BaseHandle
{
+public:
// Enumerations
/**
* @brief Enumeration for specifying the state of the key event.
- * @SINCE_1_0.0
+ * @SINCE_1_9.27
*/
enum State
{
- Down, ///< Key down @SINCE_1_0.0
- Up, ///< Key up @SINCE_1_0.0
- Last
+ DOWN, ///< Key down @SINCE_1_9.27
+ UP, ///< Key up @SINCE_1_9.27
};
/**
- * @brief Default constructor.
+ * @brief An uninitialized KeyEvent instance.
+ *
+ * Calling member functions with an uninitialized KeyEvent handle is not allowed.
* @SINCE_1_0.0
*/
KeyEvent();
/**
- * @brief Constructor.
+ * @brief Copy constructor.
+ * @SINCE_1_2.36
+ * @param[in] rhs A reference to the copied handle
+ */
+ KeyEvent(const KeyEvent& rhs);
+
+ /**
+ * @brief Move constructor.
*
- * @SINCE_1_0.0
- * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed
- * @param[in] keyString A string of input characters or key pressed
- * @param[in] keyCode The unique key code for the key pressed
- * @param[in] keyModifier The key modifier for special keys like shift and alt
- * @param[in] timeStamp The time (in ms) that the key event occurred
- * @param[in] keyState The state of the key event
+ * @SINCE_1_9.27
+ * @param[in] rhs A reference to the moved handle
*/
- KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier, unsigned long timeStamp, const State& keyState);
+ KeyEvent(KeyEvent&& rhs) noexcept;
/**
- * @brief Copy constructor.
+ * @brief Copy assignment operator.
* @SINCE_1_2.36
* @param[in] rhs A reference to the copied handle
+ * @return A reference to this
*/
- KeyEvent( const KeyEvent& rhs );
+ KeyEvent& operator=(const KeyEvent& rhs);
/**
- * @brief Assignment operator.
- * @SINCE_1_2.36
- * @param[in] rhs A reference to the copied handle
+ * @brief Move assignment operator.
+ *
+ * @SINCE_1_9.27
+ * @param[in] rhs A reference to the moved handle
* @return A reference to this
*/
- KeyEvent& operator=( const KeyEvent& rhs );
+ KeyEvent& operator=(KeyEvent&& rhs) noexcept;
/**
* @brief Destructor.
bool IsAltModifier() const;
/**
+ * @brief Get the key compose string.
+ *
+ * @SINCE_1_9.27
+ * @return The compose string
+ */
+ const std::string& GetCompose() const;
+
+ /**
* @brief Get the device name the key event originated from.
*
- * @SINCE_1_2.60
+ * @SINCE_1_9.27
* @return The device name
*/
- std::string GetDeviceName() const;
+ const std::string& GetDeviceName() const;
/**
* @brief Get the device class the key event originated from.
*/
Device::Subclass::Type GetDeviceSubclass() const;
- // Data
+ /**
+ * @brief Get the name given to the key pressed or command from the IMF
+ *
+ * @SINCE_1_9.27
+ * @return The name given to the key pressed.
+ */
+ const std::string& GetKeyName() const;
/**
- * @brief Name given to the key pressed.
+ * @brief Get the actual string of input characters that should be used for input editors.
+ *
+ * @SINCE_1_9.27
+ * @return The actual string of input characters
*/
- std::string keyPressedName;
+ const std::string& GetKeyString() const;
/**
- * @brief The actual string returned that should be used for input editors.
+ * @brief Gets the logical key string.
+ *
+ * For example, when the user presses 'shift' key and '1' key together, the logical key is "exclamation".
+ * Plus, the key name is "1", and the key string is "!".
+ *
+ * @SINCE_1_9.27
+ * @return The logical key symbol
*/
- std::string keyPressed;
+ const std::string& GetLogicalKey() const;
/**
- * @brief Keycode for the key pressed.
+ * @brief Get the unique key code for the key pressed.
+ *
+ * @SINCE_1_9.27
+ * @return The unique key code for the key pressed
*
- * @remarks We recommend not to use this key code value
- * directly because its meaning might be changed in the future. Currently, it means a
- * platform-specific key code. You need to use IsKey() to know what a key event means
- * instead of direct comparison of key code value.
+ * @remarks We recommend not to use this key code value directly because its meaning
+ * might be changed in the future. Currently, it means a platform-specific key code.
+ * You need to use IsKey() to know what a key event means instead of direct comparison
+ * of key code value.
*/
- int keyCode;
+ int32_t GetKeyCode() const;
/**
- * @brief special keys like shift, alt and control which modify the next key pressed.
+ * @brief Return the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed.
+ *
+ * @SINCE_1_9.27
+ * @return The key modifier
*/
- int keyModifier;
+ int32_t GetKeyModifier() const;
/**
- * @brief The time (in ms) that the key event occurred.
+ * @brief Get the time (in ms) that the key event occurred.
+ *
+ * @SINCE_1_9.27
+ * @return The time (in ms)
*/
- unsigned long time;
+ unsigned long GetTime() const;
/**
- * @brief State of the key event.
+ * @brief Get the state of the key event.
*
* @see State
+ *
+ * @SINCE_1_9.27
+ * @return The state of the key event
*/
- State state;
+ State GetState() const;
+public: // Not intended for application developers
+ /// @cond internal
+ /**
+ * @brief This constructor is used internally to Create an initialized KeyEvent handle.
+ *
+ * @SINCE_1_9.27
+ * @param[in] keyEvent A pointer to a newly allocated Dali resource
+ */
+ explicit DALI_INTERNAL KeyEvent(Internal::KeyEvent* keyEvent);
+ /// @endcond
};
/**
*/
} // namespace Dali
-#endif // __DALI_KEY_EVENT_H__
+#endif // DALI_KEY_EVENT_H