Skip to content

EVENT_MOUSEWHEEL with gtk3 #21853

@LaurentBerger

Description

@LaurentBerger
System information (version)
  • OpenCV => 4.5.5-310-g9aa647068b
  • Operating System / Platform => debian bullseye
  • Compiler => gcc version 10.2.1 20210110 (Raspbian 10.2.1-6+rpi1)
Detailed description

When mouse wheel is used event is wrong :

see also https://forum.opencv.org/t/unable-to-get-following-flags-event-flag-l-r-m-button-event-mousewheel/8261

Steps to reproduce
#include <opencv2/opencv.hpp>
#include <iostream>


void onMouse(int event, int x, int y, int flags, void *userdata)
{
    if (event&cv::EVENT_MOUSEWHEEL)
    {
        std::cout << "EVENT_MOUSEWHEEL" << std::endl;
        std::cout << event << std::endl;
        std::cout << cv::getMouseWheelDelta(flags) << std::endl;
    }
    if (event == cv::EVENT_MOUSEHWHEEL)
        std::cout << "EVENT_MOUSEHWHEEL" << std::endl;
    if (event == cv::EVENT_LBUTTONDOWN)
        std::cout << "EVENT_LBUTTONDOWN" << std::endl;
}

int main(int argc, char**argv)
{
    std::cout<< cv::getBuildInformation();
    cv::Mat img = cv::imread("/home/pi/opencv/samples/data/baboon.jpg", cv::IMREAD_COLOR);
    char key = 0;
    cv::namedWindow("Test Event");
    cv::setMouseCallback("Test Event", onMouse);
    while (key != 27)
    {
       if (img.empty())
            return 0;
       cv::imshow("Test Event", img);
       key = cv::pollKey();
    }

    return 0;
}

I think this line is wrong
cv_event = (event->scroll.delta_y!=0) ? CV_EVENT_MOUSEHWHEEL : CV_EVENT_MOUSEWHEEL;

May be this is good :
cv_event = (event->scroll.delta_y!=0) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions