mirror of https://github.com/axmolengine/axmol.git
CCControlExtension: Added support for SEL_CCControlHandler (as opposed to SEL_MenuHandler), which also passes the CCControlEvent parameter.
This commit is contained in:
parent
aefc1e1370
commit
df571e9cbb
|
@ -107,7 +107,7 @@ void CCControl::sendActionsForControlEvents(CCControlEvent controlEvents)
|
|||
}
|
||||
}
|
||||
}
|
||||
void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents)
|
||||
void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents)
|
||||
{
|
||||
// For each control events
|
||||
for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++)
|
||||
|
@ -135,7 +135,7 @@ void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_MenuHa
|
|||
* @param controlEvent A control event for which the action message is sent.
|
||||
* See "CCControlEvent" for constants.
|
||||
*/
|
||||
void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent)
|
||||
void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent)
|
||||
{
|
||||
// Create the invocation object
|
||||
CCInvocation *invocation=new CCInvocation(target, action, controlEvent);
|
||||
|
@ -145,7 +145,7 @@ void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHan
|
|||
eventInvocationList->addObject(invocation);
|
||||
}
|
||||
|
||||
void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents)
|
||||
void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents)
|
||||
{
|
||||
// For each control events
|
||||
for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++)
|
||||
|
@ -170,7 +170,7 @@ void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_Men
|
|||
* @param controlEvent A control event for which the action message is sent.
|
||||
* See "CCControlEvent" for constants.
|
||||
*/
|
||||
void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent)
|
||||
void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent)
|
||||
{
|
||||
// Retrieve all invocations for the given control event
|
||||
//<CCInvocation*>
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
* @param controlEvents A bitmask specifying the control events for which the
|
||||
* action message is sent. See "CCControlEvent" for bitmask constants.
|
||||
*/
|
||||
virtual void addTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents);
|
||||
virtual void addTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents);
|
||||
|
||||
/**
|
||||
* Removes a target and action for a particular event (or events) from an
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
* @param controlEvents A bitmask specifying the control events associated with
|
||||
* target and action. See "CCControlEvent" for bitmask constants.
|
||||
*/
|
||||
virtual void removeTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents);
|
||||
virtual void removeTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents);
|
||||
|
||||
/**
|
||||
* Returns a point corresponding to the touh location converted into the
|
||||
|
@ -183,7 +183,7 @@ protected:
|
|||
* @return an CCInvocation object able to construct messages using a given
|
||||
* target-action pair.
|
||||
*/
|
||||
CCInvocation* invocationWithTargetAndActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent);
|
||||
CCInvocation* invocationWithTargetAndActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent);
|
||||
|
||||
|
||||
|
||||
|
@ -199,8 +199,8 @@ protected:
|
|||
//<CCInvocation*>
|
||||
CCArray* dispatchListforControlEvent(CCControlEvent controlEvent);
|
||||
public:
|
||||
void addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent);
|
||||
void removeTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent);
|
||||
void addTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent);
|
||||
void removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent);
|
||||
|
||||
LAYER_NODE_FUNC(CCControl);
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ bool CCControlColourPicker::init()
|
|||
m_colourPicker=CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift));
|
||||
|
||||
// Setup events
|
||||
m_huePicker->addTargetWithActionForControlEvents(this, menu_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged);
|
||||
m_colourPicker->addTargetWithActionForControlEvents(this, menu_selector(CCControlColourPicker::colourSliderValueChanged), CCControlEventValueChanged);
|
||||
m_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged);
|
||||
m_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::colourSliderValueChanged), CCControlEventValueChanged);
|
||||
|
||||
// Set defaults
|
||||
updateHueAndControlPicker();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
CCInvocation::CCInvocation(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent)
|
||||
CCInvocation::CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent)
|
||||
{
|
||||
m_target=target;
|
||||
m_action=action;
|
||||
|
@ -13,7 +13,7 @@ void CCInvocation::invoke(CCObject* sender)
|
|||
{
|
||||
if (m_target && m_action)
|
||||
{
|
||||
(m_target->*m_action)(sender);
|
||||
(m_target->*m_action)(sender, m_controlEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,14 +11,18 @@ NS_CC_EXT_BEGIN
|
|||
|
||||
typedef unsigned int CCControlEvent;
|
||||
|
||||
typedef void (CCObject::*SEL_CCControlHandler)(CCObject*, CCControlEvent);
|
||||
|
||||
#define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR)
|
||||
|
||||
class CC_DLL CCInvocation : public CCObject
|
||||
{
|
||||
CC_SYNTHESIZE_READONLY(SEL_MenuHandler, m_action, Action);
|
||||
CC_SYNTHESIZE_READONLY(SEL_CCControlHandler, m_action, Action);
|
||||
CC_SYNTHESIZE_READONLY(CCObject*, m_target, Target);
|
||||
CC_SYNTHESIZE_READONLY(CCControlEvent, m_controlEvent, ControlEvent);
|
||||
|
||||
public:
|
||||
CCInvocation(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent);
|
||||
CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent);
|
||||
|
||||
void invoke(CCObject* sender);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue