[TableView] Work with mouse wheel scroll event?

[TableView] Work with mouse wheel scroll event?
0.0 0


I have a scroll view created by cc.TableView. So I want this scroll view listen to event of mouse wheel scroll on browser, is there any solutuion work with this. Please give me some advices. Thanks.


I don’t have any experince with TableView, but since some days have passed and no one replies:
Try searching for “onScrollWheel” on “samples/tests/tests-main.js” to see an example of using the scroll wheel.


I am interested in this as well. I wonder if there is a ticket for this?


Here is my implementation

    auto mouseListener = EventListenerMouse::create();
    mouseListener->onMouseScroll = [=](Event *e)
        bool notEnoughCells = tableView->minContainerOffset().y > 0;
        if (notEnoughCells)
        auto mouseEvent = dynamic_cast<EventMouse *>(e);
        if (mouseEvent)
            auto amplification = 10.f;
            auto delta = mouseEvent->getScrollY() * amplification;
            auto newOffset = tableView->getContentOffset() + Vec2(0.f, delta);
            newOffset.y = MIN(MAX(newOffset.y, tableView->minContainerOffset().y), tableView->maxContainerOffset().y);
            tableView->setContentOffsetInDuration(newOffset, 0.05);
    getEventDispatcher()->addEventListenerWithSceneGraphPriority(mouseListener, this);


NOTE: Make sure that CC_ENABLE_STACKABLE_ACTIONS is set to zero for the scrolling to work smoothly, since there might by multiple actions dispatched, and you wouldn’t want them to cascade.


this is awesome, and works great - thanks!!