2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-09 01:23:11 +08:00
|
|
|
https://axis-project.github.io/
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#ifndef __AX_IME_DISPATCHER_H__
|
|
|
|
#define __AX_IME_DISPATCHER_H__
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "base/CCIMEDelegate.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* @addtogroup base
|
2012-06-20 18:09:11 +08:00
|
|
|
* @{
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2015-03-27 12:01:20 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
@brief Input Method Edit Message Dispatcher.
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
class AX_DLL IMEDispatcher
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
~IMEDispatcher();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* @brief Returns the shared IMEDispatcher object for the system.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static IMEDispatcher* sharedDispatcher();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* @brief Dispatches the input text from IME.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void dispatchInsertText(const char* text, size_t len);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* @brief Dispatches the delete-backward operation.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @lua NA
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
void dispatchDeleteBackward();
|
|
|
|
|
2016-03-07 19:22:03 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* @brief Dispatches the press control key operation.
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2016-03-07 19:22:03 +08:00
|
|
|
void dispatchControlKey(EventKeyboard::KeyCode keyCode);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* @brief Get the content text from IMEDelegate, retrieved previously from IME.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view getContentText();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// dispatch keyboard notification
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void dispatchKeyboardWillShow(IMEKeyboardNotificationInfo& info);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void dispatchKeyboardDidShow(IMEKeyboardNotificationInfo& info);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void dispatchKeyboardWillHide(IMEKeyboardNotificationInfo& info);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void dispatchKeyboardDidHide(IMEKeyboardNotificationInfo& info);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
friend class IMEDelegate;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief Add delegate to receive IME messages.
|
|
|
|
*@param delegate A instance implements IMEDelegate delegate.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void addDelegate(IMEDelegate* delegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief Attach the Delegate to the IME.
|
|
|
|
*@param delegate A instance implements IMEDelegate delegate.
|
2021-12-25 10:04:45 +08:00
|
|
|
*@return If the old delegate can detach from the IME, and the new delegate
|
2015-03-25 18:17:58 +08:00
|
|
|
* can attach to the IME, return true, otherwise false.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
bool attachDelegateWithIME(IMEDelegate* delegate);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* Detach the delegate to the IME
|
2015-03-25 18:17:58 +08:00
|
|
|
*@see `attachDelegateWithIME(IMEDelegate*)`
|
|
|
|
*@param delegate A instance implements IMEDelegate delegate.
|
|
|
|
*@return Whether the IME is detached or not.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
bool detachDelegateWithIME(IMEDelegate* delegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief Remove the delegate from the delegates which receive IME messages.
|
|
|
|
*@param delegate A instance implements the IMEDelegate delegate.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void removeDelegate(IMEDelegate* delegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
private:
|
2013-06-20 14:13:12 +08:00
|
|
|
IMEDispatcher();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
class Impl;
|
2021-12-25 10:04:45 +08:00
|
|
|
Impl* _impl;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2015-03-27 12:01:20 +08:00
|
|
|
// end of base group
|
|
|
|
/// @}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // __AX_IME_DISPATCHER_H__
|