2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (C) 2013-2014 Chukong Technologies Inc.
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CC_IME_DELEGATE_H__
|
|
|
|
#define __CC_IME_DELEGATE_H__
|
|
|
|
|
2013-12-24 15:49:58 +08:00
|
|
|
#include <string>
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "base/CCGeometry.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
2013-12-24 15:49:58 +08:00
|
|
|
extern const std::string STD_STRING_EMPTY;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup input
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
Rect begin; // the soft keyboard rectangle when animation begins
|
|
|
|
Rect end; // the soft keyboard rectangle when animation ends
|
2012-04-19 14:35:52 +08:00
|
|
|
float duration; // the soft keyboard animation duration
|
2013-06-20 14:13:12 +08:00
|
|
|
} IMEKeyboardNotificationInfo;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Input method editor delegate.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL IMEDelegate
|
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
|
|
|
virtual ~IMEDelegate();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool attachWithIME();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool detachWithIME();
|
|
|
|
|
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
friend class IMEDispatcher;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2012-09-17 15:02:24 +08:00
|
|
|
@brief Decide if the delegate instance is ready to receive an IME message.
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Called by IMEDispatcher.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
virtual bool canAttachWithIME() { return false; }
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief When the delegate detaches from the IME, this method is called by IMEDispatcher.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
virtual void didAttachWithIME() {}
|
|
|
|
|
|
|
|
/**
|
2012-09-17 15:02:24 +08:00
|
|
|
@brief Decide if the delegate instance can stop receiving IME messages.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
virtual bool canDetachWithIME() { return false; }
|
|
|
|
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief When the delegate detaches from the IME, this method is called by IMEDispatcher.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
virtual void didDetachWithIME() {}
|
|
|
|
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Called by IMEDispatcher when text input received from the IME.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-03-20 10:58:04 +08:00
|
|
|
virtual void insertText(const char * text, size_t len) {CC_UNUSED_PARAM(text);CC_UNUSED_PARAM(len);}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Called by IMEDispatcher after the user clicks the backward key.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
virtual void deleteBackward() {}
|
|
|
|
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Called by IMEDispatcher for text stored in delegate.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-12-24 15:49:58 +08:00
|
|
|
virtual const std::string& getContentText() { return STD_STRING_EMPTY; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// keyboard show/hide notification
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
IMEDelegate();
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of input group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // __CC_IME_DELEGATE_H__
|