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.
|
|
|
|
|
2022-10-01 16:24:52 +08:00
|
|
|
https://axmolengine.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_DELEGATE_H__
|
|
|
|
#define __AX_IME_DELEGATE_H__
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
#include <string>
|
2021-10-23 23:27:14 +08:00
|
|
|
#include "math/CCMath.h"
|
2019-11-23 20:27:39 +08:00
|
|
|
#include "base/CCEventKeyboard.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup base
|
|
|
|
* @{
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A static global empty std::string install.
|
|
|
|
*/
|
2022-07-16 10:43:05 +08:00
|
|
|
extern const std::string AX_DLL STD_STRING_EMPTY;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Keyboard notification event type.
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Rect begin; // the soft keyboard rectangle when animation begins
|
|
|
|
Rect end; // the soft keyboard rectangle when animation ends
|
|
|
|
float duration; // the soft keyboard animation duration
|
2019-11-23 20:27:39 +08:00
|
|
|
} IMEKeyboardNotificationInfo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*@brief Input method editor delegate.
|
|
|
|
*/
|
2022-07-16 10:43:05 +08:00
|
|
|
class AX_DLL IMEDelegate
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~IMEDelegate();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/**
|
|
|
|
* Default destructor.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual bool attachWithIME();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/**
|
|
|
|
* Determine whether the IME is detached or not.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual bool detachWithIME();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class IMEDispatcher;
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Decide if the delegate instance is ready to receive an IME message.
|
|
|
|
|
|
|
|
Called by IMEDispatcher.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual bool canAttachWithIME() { return false; }
|
|
|
|
/**
|
|
|
|
@brief When the delegate detaches from the IME, this method is called by IMEDispatcher.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual void didAttachWithIME() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Decide if the delegate instance can stop receiving IME messages.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual bool canDetachWithIME() { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief When the delegate detaches from the IME, this method is called by IMEDispatcher.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual void didDetachWithIME() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Called by IMEDispatcher when text input received from the IME.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual void insertText(const char* /*text*/, size_t /*len*/) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Called by IMEDispatcher after the user clicks the backward key.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual void deleteBackward() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Called by IMEDispatcher after the user press control key.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual void controlKey(EventKeyboard::KeyCode /*keyCode*/) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Called by IMEDispatcher for text stored in delegate.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-31 12:12:40 +08:00
|
|
|
virtual std::string_view getContentText() { return STD_STRING_EMPTY; }
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// keyboard show/hide notification
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void keyboardWillShow(IMEKeyboardNotificationInfo& /*info*/) {}
|
2019-11-23 20:27:39 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void keyboardDidShow(IMEKeyboardNotificationInfo& /*info*/) {}
|
2019-11-23 20:27:39 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void keyboardWillHide(IMEKeyboardNotificationInfo& /*info*/) {}
|
2019-11-23 20:27:39 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& /*info*/) {}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
IMEDelegate();
|
|
|
|
};
|
|
|
|
|
2022-07-11 17:50:21 +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_DELEGATE_H__
|