2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
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_DISPATCHER_H__
|
|
|
|
#define __CC_IME_DISPATCHER_H__
|
|
|
|
|
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
|
|
|
* @{
|
|
|
|
*/
|
2015-03-27 12:01:20 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
@brief Input Method Edit Message Dispatcher.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_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
|
|
|
|
*/
|
2014-03-20 10:58:04 +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();
|
|
|
|
|
|
|
|
/**
|
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
|
|
|
|
*/
|
2013-12-24 15:49:58 +08:00
|
|
|
const std::string& 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.
|
|
|
|
*/
|
2013-12-18 17:47:20 +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.
|
|
|
|
*@return If the old delegate can detach from the IME, and the new delegate
|
|
|
|
* can attach to the IME, return true, otherwise false.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
bool attachDelegateWithIME(IMEDelegate * delegate);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dettach the delegate to the IME
|
|
|
|
*@see `attachDelegateWithIME(IMEDelegate*)`
|
|
|
|
*@param delegate A instance implements IMEDelegate delegate.
|
|
|
|
*@return Whether the IME is detached or not.
|
|
|
|
*/
|
2013-12-18 17:47:20 +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.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
void removeDelegate(IMEDelegate * delegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
private:
|
2013-06-20 14:13:12 +08:00
|
|
|
IMEDispatcher();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
class Impl;
|
2013-06-15 14:03:30 +08:00
|
|
|
Impl * _impl;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
2015-03-27 12:01:20 +08:00
|
|
|
// end of base group
|
|
|
|
/// @}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
#endif // __CC_IME_DISPATCHER_H__
|