Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. emscripten_set_mousedown_callback does not call the callback function

emscripten_set_mousedown_callback does not call the callback function

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
6 Posts 1 Posters 421 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by 8Observer8
    #1

    emscripten_set_mousedown_callback does not call the callback function. I expect to see the output in the console but I see nothing:

    #include <QtWidgets/QApplication>
    #include <QtWidgets/QWidget>
    
    #include <emscripten.h>
    #include <emscripten/html5.h>
    
    class Widget : public QWidget
    {
    
    public:
    
        Widget()
        {
            emscripten_set_mousedown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, 0, +[](int eventType,
                const EmscriptenMouseEvent* e, void* userData) -> EM_BOOL
            {
                qDebug() << "Mouse down: " << e->button;
                return EM_FALSE;
            });
        }
    };
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        Widget w;
        w.show();
        return app.exec();
    }
    
    1 Reply Last reply
    0
    • 8Observer88 Offline
      8Observer88 Offline
      8Observer8
      wrote on last edited by
      #2

      Bug report: https://bugreports.qt.io/browse/QTBUG-126582

      1 Reply Last reply
      1
      • 8Observer88 8Observer8 referenced this topic on
      • 8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by 8Observer8
        #3

        I have tried to make an "Empty qmake Project":

        image.png

        pro

        wasm: INCLUDEPATH += "C:\emsdk\upstream\emscripten\cache\sysroot\include"
        
        SOURCES += \
            main.cpp
        

        main.cpp

        #include <emscripten.h>
        #include <emscripten/html5.h>
        #include <iostream>
        
        // https://github.com/emscripten-core/emscripten/issues/19266
        int main()
        {
            // Mouse Button Down:
            emscripten_set_mousedown_callback(
                EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, 0, +[](int eventType,
                const EmscriptenMouseEvent *e, void *userData) -> EM_BOOL
                {
                    std::cout << "Mouse down: " << e->button << "\n";
                    return EM_FALSE;
                });
        }
        

        It doesn't print the output to the console when I click.

        But it works when I compile from the console:

        emcc -g main.cpp -o public/index.html

        1 Reply Last reply
        0
        • 8Observer88 Offline
          8Observer88 Offline
          8Observer8
          wrote on last edited by 8Observer8
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • 8Observer88 Offline
            8Observer88 Offline
            8Observer8
            wrote on last edited by 8Observer8
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • 8Observer88 Offline
              8Observer88 Offline
              8Observer8
              wrote on last edited by 8Observer8
              #6

              The Emscripten issue: emscripten_set_mousedown_callback does not call the callback function from Qt Creator

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved