CCScrollView Issues: Can't scroll when touching contents & Tapping outside of ScrollView still hits clipped items


#1

So I have a ScrollView filled with MenuItems that each have a MenuItemImage (ScrollerButton inherits it) in it.
The idea is to have a scrollable space filled with images that are tappable. When tapped they call a function in the same class.

Once the ScrollView is set up however I can only scroll by holding down and dragging on the space between the MenuItems.
Also, if the content is clipped by the bounds of the ScrollView, it can still be tapped by tapping where it would be if the ScrollView were larger.

Some code:

Here is the ScrollView setup

extension::CCScrollView* FooScene::setupScroller(CCSize size)
{
    extension::CCScrollView* scroller = extension::CCScrollView::create(size);
    scroller->retain();
    scroller->setAnchorPoint(ccp(0, 0));
    scroller->setPosition(ccp(panel1->getContentSize().width, 0));
    scroller->setDirection(extension::kCCScrollViewDirectionHorizontal);
    menuLayer->addChild(scroller,SCROLLER_Z_DEPTH); 


    return scroller;
}

And here is the code for populating the ScrollView

void FooScene::addStickerThumbsToScrollView()
{


    int lastpos = 0;

    CCMenu *menu = CCMenu::create();
    menu->setAnchorPoint(ccp(0, 0));
    menu->setPosition(ccp(0, 0));


     for (int i = 0; i < thumbnailArray->count(); i++) {

         std::string imageName = ((CCString*)thumbnailArray->objectAtIndex(i))->getCString();
         std::string imagePath = Utils::platformSpecificPath("images/stickers/thumbs/" + imageName + "_thumb","png" );

         ScrollerButton *SButton = ScrollerButton::create();
         SButton->setNormalImage(CCSprite::create(imagePath.c_str()));
         SButton->initWithTarget(this, menu_selector(FooScene::scrollThumbButtonPushed));

         SButton->setAnchorPoint(ccp(0, 0));
         SButton->setPosition(ccp(lastpos, 0));
         SButton->setDelegate(this);
         SButton->setName(imageName);

         menu->addChild(SButton);

         lastpos += SButton->getContentSize().width;

    }

    myScroller->addChild(menu);

    myScroller->setContentSize(CCSizeMake(lastpos, myScroller->getContentSize().height));

}

ScrollerButton.h

#include "cocos2d.h"

using namespace cocos2d;

class ScrollerButton : public CCMenuItemImage, public CCTargetedTouchDelegate
{
private:
    std::string name;
    CCTouchDelegate *delegate;

public:

    //Properties
    std::string getName() { return this->name; }
    void setName(std::string newName) { this->name = newName; }

    CCTouchDelegate* getDelegate () { return this->delegate; }
    void setDelegate(CCTouchDelegate* newDelegate) { this->delegate = newDelegate; }


    virtual bool init();
    virtual void onEnter();
    virtual void onExit();

    CREATE_FUNC(ScrollerButton);
};

ScrollerButton.ccp

#include "ScrollerButton.h"
#include "cocos2d.h"

using namespace cocos2d;

bool ScrollerButton::init()
{
    if(!CCMenuItemImage::init())
    {
        return false;
    }
    this->name = "";

    return true;

}

void ScrollerButton::onEnter()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 5, false);
    CCMenuItemImage::onEnter();
}
void ScrollerButton::onExit()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
    CCMenuItemImage::onExit();
}

Tried a few different things with addTargetedDelegate(this, 5, false);