diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 13d86e629c..15fe7b1a8d 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -326,4 +326,9 @@ bool Control::hasVisibleParents() const } return true; } + +Control::EventType operator|(Control::EventType a, Control::EventType b) { + return static_cast(static_cast(a) | static_cast(b)); +} + NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index d8644a516f..12533f7041 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -262,6 +262,8 @@ protected: CC_SYNTHESIZE_READONLY(State, _state, State); }; +Control::EventType operator|(Control::EventType a, Control::EventType b); + // end of GUI group /// @} /// @} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index a7fe134383..d5914b2db1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -110,6 +110,7 @@ ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(cons ControlButtonTest_Event::ControlButtonTest_Event() : _displayValueLabel(NULL) +, _displayBitmaskLabel(NULL) { } @@ -117,6 +118,7 @@ ControlButtonTest_Event::ControlButtonTest_Event() ControlButtonTest_Event::~ControlButtonTest_Event() { CC_SAFE_RELEASE_NULL(_displayValueLabel); + CC_SAFE_RELEASE_NULL(_displayBitmaskLabel); } bool ControlButtonTest_Event::init() @@ -130,7 +132,13 @@ bool ControlButtonTest_Event::init() _displayValueLabel->setAnchorPoint(Point(0.5f, -1)); _displayValueLabel->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(_displayValueLabel, 1); - + + setDisplayBitmaskLabel(LabelTTF::create("No bitmask event", "Marker Felt", 24)); + _displayBitmaskLabel->setAnchorPoint(Point(0.5f, -1)); + Point bitmaskLabelPos = _displayValueLabel->getPosition() - Point(0, _displayBitmaskLabel->getBoundingBox().size.height); + _displayBitmaskLabel->setPosition(bitmaskLabelPos); + addChild(_displayBitmaskLabel, 1); + // Add the button auto backgroundButton = Scale9Sprite::create("extensions/button.png"); auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); @@ -162,11 +170,20 @@ bool ControlButtonTest_Event::init() controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE); controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE); controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), Control::EventType::TOUCH_CANCEL); + // test for issue 2882 + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchBitmaskAction), + Control::EventType::TOUCH_DOWN | Control::EventType::DRAG_INSIDE | Control::EventType::DRAG_OUTSIDE | Control::EventType::DRAG_ENTER | Control::EventType::DRAG_EXIT | Control::EventType::TOUCH_UP_INSIDE | Control::EventType::TOUCH_UP_OUTSIDE | Control::EventType::TOUCH_CANCEL | Control::EventType::VALUE_CHANGED); + return true; } return false; } +void ControlButtonTest_Event::touchBitmaskAction(Object *senderz, Control::EventType controlEvent) +{ + _displayBitmaskLabel->setString(String::createWithFormat("using bitmask (%d)", controlEvent)->getCString()); +} + void ControlButtonTest_Event::touchDownAction(Object *senderz, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString()); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h index 6e4d602107..1efbf9c604 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h @@ -54,8 +54,10 @@ public: void touchUpInsideAction(Object *sender, Control::EventType controlEvent); void touchUpOutsideAction(Object *sender, Control::EventType controlEvent); void touchCancelAction(Object *sender, Control::EventType controlEvent); + void touchBitmaskAction(Object *sender, Control::EventType controlEvent); protected: CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel) + CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayBitmaskLabel, DisplayBitmaskLabel) CONTROL_SCENE_CREATE_FUNC(ControlButtonTest_Event) };