axmol/core/base/CCIMEDispatcher.h

144 lines
4.1 KiB
C
Raw Normal View History

2019-11-23 20:27:39 +08:00
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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-08-08 18:02:17 +08:00
https://axys1.github.io/
2019-11-23 20:27:39 +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-16 10:43:05 +08:00
#ifndef __AX_IME_DISPATCHER_H__
#define __AX_IME_DISPATCHER_H__
2019-11-23 20:27:39 +08:00
#include "base/CCIMEDelegate.h"
/**
* @addtogroup base
* @{
*/
NS_AX_BEGIN
2019-11-23 20:27:39 +08:00
/**
@brief Input Method Edit Message Dispatcher.
*/
2022-07-16 10:43:05 +08:00
class AX_DLL IMEDispatcher
2019-11-23 20:27:39 +08:00
{
public:
/**
* @js NA
* @lua NA
*/
~IMEDispatcher();
/**
* @brief Returns the shared IMEDispatcher object for the system.
* @js NA
* @lua NA
*/
static IMEDispatcher* sharedDispatcher();
/**
* @brief Dispatches the input text from IME.
* @lua NA
*/
2021-12-25 10:04:45 +08:00
void dispatchInsertText(const char* text, size_t len);
2019-11-23 20:27:39 +08:00
/**
* @brief Dispatches the delete-backward operation.
* @lua NA
*/
void dispatchDeleteBackward();
/**
2021-12-25 10:04:45 +08:00
* @brief Dispatches the press control key operation.
* @lua NA
*/
2019-11-23 20:27:39 +08:00
void dispatchControlKey(EventKeyboard::KeyCode keyCode);
/**
* @brief Get the content text from IMEDelegate, retrieved previously from IME.
* @lua NA
*/
std::string_view getContentText();
2019-11-23 20:27:39 +08:00
//////////////////////////////////////////////////////////////////////////
// dispatch keyboard notification
//////////////////////////////////////////////////////////////////////////
/**
* @lua NA
*/
void dispatchKeyboardWillShow(IMEKeyboardNotificationInfo& info);
/**
* @lua NA
*/
void dispatchKeyboardDidShow(IMEKeyboardNotificationInfo& info);
/**
* @lua NA
*/
void dispatchKeyboardWillHide(IMEKeyboardNotificationInfo& info);
/**
* @lua NA
*/
void dispatchKeyboardDidHide(IMEKeyboardNotificationInfo& info);
protected:
friend class IMEDelegate;
/**
*@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);
2019-11-23 20:27:39 +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
2019-11-23 20:27:39 +08:00
* can attach to the IME, return true, otherwise false.
*/
2021-12-25 10:04:45 +08:00
bool attachDelegateWithIME(IMEDelegate* delegate);
2019-11-23 20:27:39 +08:00
/**
* Detach the delegate to the IME
*@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);
2019-11-23 20:27:39 +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);
2019-11-23 20:27:39 +08:00
private:
IMEDispatcher();
2021-12-25 10:04:45 +08:00
2019-11-23 20:27:39 +08:00
class Impl;
2021-12-25 10:04:45 +08:00
Impl* _impl;
2019-11-23 20:27:39 +08:00
};
NS_AX_END
2019-11-23 20:27:39 +08:00
// end of base group
/// @}
2022-07-16 10:43:05 +08:00
#endif // __AX_IME_DISPATCHER_H__