Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simulate left mouse button unclick (release button)
Forum Updated to NodeBB v4.3 + New Features

Simulate left mouse button unclick (release button)

Scheduled Pinned Locked Moved Solved General and Desktop
31 Posts 3 Posters 14.3k Views 3 Watching
  • 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.
  • mrjjM mrjj

    Hi
    Something else is wrong I think.
    Maybe the touch controller only sends MouseDown event or the up event get eaten somehow.

    Does touch work correctly with buttons?
    Click and hold the button. It should stay down. Then release and it go up.

    You can construct a Mouse Event yourself and send it but i would look for other reason before trying that.

    A Offline
    A Offline
    Andrey Shmelew
    wrote on last edited by
    #3

    @mrjj
    Hi! if we are talking about buttons, all works fine, when i hold finger on the button it stays down.
    When i click on combobox, it opens and shows all submenus. When i release my finger, combobox becomes normal. After it i touch on any other area, and for somehow this combobox becomes opened again, as if I pressed it again (but i did not). At this moment we have button pressed event and i can not press other buttons.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Hi, sounds like the combobox eats the events after.

      Is this a std combo box?

      When you click outside, it should not stay open.

      A 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi, sounds like the combobox eats the events after.

        Is this a std combo box?

        When you click outside, it should not stay open.

        A Offline
        A Offline
        Andrey Shmelew
        wrote on last edited by Andrey Shmelew
        #5

        @mrjj
        i think it is std combobox

        the problem exsists if only i use touch screen (connected by USB). if i click outside it stays open for a while, and then when i clicked outside second time - combobox closes (and "finger" click becomes pressed forewer),

        If i manipulate by regular USB mouse, comboboxes are working fine!

        So, i want to try to generate mous unclick event

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #6

          well
          the drop down part of a combo box is using an event filter. I think its related to this but
          not sure. If it works with a real mouse, why not with touch ?

          Do you use real touch events or did you tell it to act like a mouse? ( the touch controller)

          Well, no harm in trying but I guess it will just be eaten too
          QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
          QCoreApplication::sendEvent(QWidget::focusWidget(),mEvnRelease);

          Did you try with other applications?
          Anything with a combobox should do the same. :)

          A 1 Reply Last reply
          1
          • mrjjM mrjj

            well
            the drop down part of a combo box is using an event filter. I think its related to this but
            not sure. If it works with a real mouse, why not with touch ?

            Do you use real touch events or did you tell it to act like a mouse? ( the touch controller)

            Well, no harm in trying but I guess it will just be eaten too
            QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
            QCoreApplication::sendEvent(QWidget::focusWidget(),mEvnRelease);

            Did you try with other applications?
            Anything with a combobox should do the same. :)

            A Offline
            A Offline
            Andrey Shmelew
            wrote on last edited by Andrey Shmelew
            #7

            @mrjj
            hmmm...

            i use yours code:

            void MainWindow::mousePressEvent(QMouseEvent* event)
            {
                if(event->buttons() == Qt::RightButton)
                    ui->label_7->setText("Only right button");
                if(event->buttons() == Qt::LeftButton)
                    ui->label_7->setText("Only left button");
                QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QCoreApplication::sendEvent(QWidget::focusWidget(),mEvnRelease);
            }
            

            , it works now better, but even if MouseButtonRelease event exsists, buttons somehow becomes untouchable.

            "Do you use real touch events or did you tell it to act like a mouse? ( the touch controller)"

            it acts like a mouse (touch controller presents)!

            I have uploaded example project with combobox to the device, and there is exactly the same problem.

            mrjjM 1 Reply Last reply
            0
            • A Andrey Shmelew

              @mrjj
              hmmm...

              i use yours code:

              void MainWindow::mousePressEvent(QMouseEvent* event)
              {
                  if(event->buttons() == Qt::RightButton)
                      ui->label_7->setText("Only right button");
                  if(event->buttons() == Qt::LeftButton)
                      ui->label_7->setText("Only left button");
                  QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                  QCoreApplication::sendEvent(QWidget::focusWidget(),mEvnRelease);
              }
              

              , it works now better, but even if MouseButtonRelease event exsists, buttons somehow becomes untouchable.

              "Do you use real touch events or did you tell it to act like a mouse? ( the touch controller)"

              it acts like a mouse (touch controller presents)!

              I have uploaded example project with combobox to the device, and there is exactly the same problem.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #8

              @Andrey-Shmelew
              Hmm really sounds like the touch controller is not acting as a mouse and only
              sends touch events.

              You could set a event filter and watch what events you get.
              http://www.informit.com/articles/article.aspx?p=1405544&seqNum=2

              also note with the code its sends m up to the focused control so if it was not the
              same control that got Mouse Press, it will not work.

              Ps. to get names and not ints for the events, you can use
              https://www.dropbox.com/s/rujoldiax0cql3z/names.txt?dl=0

              A 1 Reply Last reply
              1
              • mrjjM mrjj

                @Andrey-Shmelew
                Hmm really sounds like the touch controller is not acting as a mouse and only
                sends touch events.

                You could set a event filter and watch what events you get.
                http://www.informit.com/articles/article.aspx?p=1405544&seqNum=2

                also note with the code its sends m up to the focused control so if it was not the
                same control that got Mouse Press, it will not work.

                Ps. to get names and not ints for the events, you can use
                https://www.dropbox.com/s/rujoldiax0cql3z/names.txt?dl=0

                A Offline
                A Offline
                Andrey Shmelew
                wrote on last edited by
                #9

                @mrjj

                thank you for the link, sir!

                i have event handler:

                void MainWindow::mouseReleaseEvent(QMouseEvent* event)
                {
                    ui->label_7->setText("button Released");
                }
                

                and touch controller sends this event.

                maybe, it sends mouseReleaseEvent properly not every time i when i touch

                A mrjjM 2 Replies Last reply
                0
                • A Andrey Shmelew

                  @mrjj

                  thank you for the link, sir!

                  i have event handler:

                  void MainWindow::mouseReleaseEvent(QMouseEvent* event)
                  {
                      ui->label_7->setText("button Released");
                  }
                  

                  and touch controller sends this event.

                  maybe, it sends mouseReleaseEvent properly not every time i when i touch

                  A Offline
                  A Offline
                  Andrey Shmelew
                  wrote on last edited by
                  #10

                  i found a bug,
                  in my project i have a dial control...
                  firstly i touched to control and manipulated a litlle bit,
                  then i touched free area (without any controls or widgets) and noticed than dial reacts on my touching and rotates in direct of my touch spot (i did not touch dial but it turned).

                  1 Reply Last reply
                  0
                  • A Andrey Shmelew

                    @mrjj

                    thank you for the link, sir!

                    i have event handler:

                    void MainWindow::mouseReleaseEvent(QMouseEvent* event)
                    {
                        ui->label_7->setText("button Released");
                    }
                    

                    and touch controller sends this event.

                    maybe, it sends mouseReleaseEvent properly not every time i when i touch

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @Andrey-Shmelew
                    Well you can check with mouseReleaseEvent if it fires every time.
                    If yes, then something else is still not 100% like a mouse.

                    I had some issues with some widgets that look for mouse move and mouse leave events ( focusin/out)
                    which is not (always) send with a touch. But I dont remember a plain combobox being an issue.

                    Have you tested with some non Qt app ?
                    Does it accept the touch fully as a mouse?

                    A 2 Replies Last reply
                    1
                    • mrjjM mrjj

                      @Andrey-Shmelew
                      Well you can check with mouseReleaseEvent if it fires every time.
                      If yes, then something else is still not 100% like a mouse.

                      I had some issues with some widgets that look for mouse move and mouse leave events ( focusin/out)
                      which is not (always) send with a touch. But I dont remember a plain combobox being an issue.

                      Have you tested with some non Qt app ?
                      Does it accept the touch fully as a mouse?

                      A Offline
                      A Offline
                      Andrey Shmelew
                      wrote on last edited by
                      #12

                      @mrjj
                      i will answer tomorrow! need to go :(
                      Thank you!

                      1 Reply Last reply
                      1
                      • mrjjM mrjj

                        @Andrey-Shmelew
                        Well you can check with mouseReleaseEvent if it fires every time.
                        If yes, then something else is still not 100% like a mouse.

                        I had some issues with some widgets that look for mouse move and mouse leave events ( focusin/out)
                        which is not (always) send with a touch. But I dont remember a plain combobox being an issue.

                        Have you tested with some non Qt app ?
                        Does it accept the touch fully as a mouse?

                        A Offline
                        A Offline
                        Andrey Shmelew
                        wrote on last edited by Andrey Shmelew
                        #13

                        @mrjj
                        Hello and Happy New Year!

                        I installed VLC media player on my beaglebone, and have been playing with controls (combobox, scrollbars etc...), and all was going well, no bugs with comboboxes, touch screen clicks and releases fine.
                        I noticed that combobox in VLC player and combobox in QT are differented of each other.

                        VLC acceps the touch fully as a mouse, i suppose.

                        mrjjM 1 Reply Last reply
                        0
                        • A Andrey Shmelew

                          @mrjj
                          Hello and Happy New Year!

                          I installed VLC media player on my beaglebone, and have been playing with controls (combobox, scrollbars etc...), and all was going well, no bugs with comboboxes, touch screen clicks and releases fine.
                          I noticed that combobox in VLC player and combobox in QT are differented of each other.

                          VLC acceps the touch fully as a mouse, i suppose.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          @Andrey-Shmelew
                          Hi
                          Happy new year to you too

                          Ok it does sound like it is working as it should. Maybe VLC is very touch friendly.

                          Can we test with one app ( nothing as well used with touch as VLC ) to test ?

                          Still think its just controller that slips a mouse up sometimes but not sure yet.

                          A 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @Andrey-Shmelew
                            Hi
                            Happy new year to you too

                            Ok it does sound like it is working as it should. Maybe VLC is very touch friendly.

                            Can we test with one app ( nothing as well used with touch as VLC ) to test ?

                            Still think its just controller that slips a mouse up sometimes but not sure yet.

                            A Offline
                            A Offline
                            Andrey Shmelew
                            wrote on last edited by
                            #15

                            @mrjj said in Simulate left mouse button unclick (release button):

                            Can we test with one app ( nothing as well used with touch as VLC ) to test ?

                            yes, sure, i will try evrethyng i can

                            mrjjM 1 Reply Last reply
                            0
                            • A Andrey Shmelew

                              @mrjj said in Simulate left mouse button unclick (release button):

                              Can we test with one app ( nothing as well used with touch as VLC ) to test ?

                              yes, sure, i will try evrethyng i can

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by mrjj
                              #16

                              @Andrey-Shmelew
                              Super
                              Did you also check with main window that
                              void MainWindow::mouseReleaseEvent(QMouseEvent* event)
                              {
                              qDebug() << ("button Released");
                              }

                              is always called?
                              Make sure only to click on the mainwindow.

                              A 1 Reply Last reply
                              0
                              • mrjjM mrjj

                                @Andrey-Shmelew
                                Super
                                Did you also check with main window that
                                void MainWindow::mouseReleaseEvent(QMouseEvent* event)
                                {
                                qDebug() << ("button Released");
                                }

                                is always called?
                                Make sure only to click on the mainwindow.

                                A Offline
                                A Offline
                                Andrey Shmelew
                                wrote on last edited by Andrey Shmelew
                                #17

                                @mrjj said in Simulate left mouse button unclick (release button):

                                is always called

                                if only i did not press combobox...

                                As soon as I clicked combobox, no matter how many times I clicked on the mainwindow, label_7 is always "Only left button"

                                qDebug() << ("button Released"); is not working in linux app, so i use label_7 as debug out

                                mrjjM 1 Reply Last reply
                                0
                                • A Andrey Shmelew

                                  @mrjj said in Simulate left mouse button unclick (release button):

                                  is always called

                                  if only i did not press combobox...

                                  As soon as I clicked combobox, no matter how many times I clicked on the mainwindow, label_7 is always "Only left button"

                                  qDebug() << ("button Released"); is not working in linux app, so i use label_7 as debug out

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #18

                                  @Andrey-Shmelew
                                  Yes combo is special as it drop down a floating window and use event filer for selection so
                                  it is not canceled correctly, it will then eat all events and nothing else can be clicked.

                                  ehh qDebug() not working in linux ? you mean outside Creator or ?
                                  Dont matter. Label is fine :)

                                  A 1 Reply Last reply
                                  1
                                  • mrjjM mrjj

                                    @Andrey-Shmelew
                                    Yes combo is special as it drop down a floating window and use event filer for selection so
                                    it is not canceled correctly, it will then eat all events and nothing else can be clicked.

                                    ehh qDebug() not working in linux ? you mean outside Creator or ?
                                    Dont matter. Label is fine :)

                                    A Offline
                                    A Offline
                                    Andrey Shmelew
                                    wrote on last edited by
                                    #19

                                    @mrjj
                                    Hello!

                                    So, the problem is not solved,
                                    should i use events filter?

                                    thanks!

                                    mrjjM 1 Reply Last reply
                                    0
                                    • A Andrey Shmelew

                                      @mrjj
                                      Hello!

                                      So, the problem is not solved,
                                      should i use events filter?

                                      thanks!

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by mrjj
                                      #20

                                      @Andrey-Shmelew
                                      well, i would dig a bit deeper into what is going on.
                                      I never seen combo not work like that.
                                      Seems something else than missing events.

                                      But yes, you can most likely work around using event filters but there might surface other stuff
                                      like broken drag and drop or something as its not a bug in combobox ( no other reports) as such so
                                      something else is not as expected with the touch.

                                      I tried at work with touch screen and could not reproduce it so Im a bit lost why
                                      its not just closing its dropdown.

                                      I think it will/might be a mess with eventfilter
                                      but if you only have one combobox you
                                      need to fix it should be ok
                                      but if you use combos all over program i would
                                      go for better solution.

                                      A 1 Reply Last reply
                                      1
                                      • mrjjM mrjj

                                        @Andrey-Shmelew
                                        well, i would dig a bit deeper into what is going on.
                                        I never seen combo not work like that.
                                        Seems something else than missing events.

                                        But yes, you can most likely work around using event filters but there might surface other stuff
                                        like broken drag and drop or something as its not a bug in combobox ( no other reports) as such so
                                        something else is not as expected with the touch.

                                        I tried at work with touch screen and could not reproduce it so Im a bit lost why
                                        its not just closing its dropdown.

                                        I think it will/might be a mess with eventfilter
                                        but if you only have one combobox you
                                        need to fix it should be ok
                                        but if you use combos all over program i would
                                        go for better solution.

                                        A Offline
                                        A Offline
                                        Andrey Shmelew
                                        wrote on last edited by
                                        #21

                                        @mrjj
                                        Unfortunately, i use combos all over program. I want to use comboboxes for configure my device. if you could not reproduce it, maybe it happens because of my touch's non-correct work. If i could make any help for you for help me ...

                                        mrjjM raven-worxR 2 Replies Last reply
                                        0
                                        • A Andrey Shmelew

                                          @mrjj
                                          Unfortunately, i use combos all over program. I want to use comboboxes for configure my device. if you could not reproduce it, maybe it happens because of my touch's non-correct work. If i could make any help for you for help me ...

                                          mrjjM Offline
                                          mrjjM Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on last edited by mrjj
                                          #22

                                          @Andrey-Shmelew

                                          Hmm, I asked another mod here for some input (later) as there is something
                                          funky here. Maybe im overlooking something.
                                          If your touch acts as pure touch or is faulty then other controls should also have issues.

                                          But since we do not have any event trace is very unclear what is happening.
                                          Also as far as I know, the drop down part of the combobox is already using event filter.
                                          So its not sure event filters are a good/easy fix.

                                          I think i would still dig deeper to find real reason. ( look in Qt source)

                                          Alternatively, make my own combo box and control the dropdown with lost focus if possible.
                                          Didnt check the code so not sure how it handles the dropdown.

                                          1 Reply Last reply
                                          1

                                          • Login

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