Results 1 to 5 of 5

Thread: Get mouse events in MAC

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Get mouse events in MAC

    We got the mouse events on the title bar using the following code in windows
    Qt Code:
    1. bool RightSideBar::winEvent(MSG *msg, long *result)
    2. {
    3. if (msg->message == WM_NCLBUTTONUP)
    4. {
    5. //here can catch the leftmousedown event on titlebar
    6. qDebug()<<"Title Bar Button Down";
    7. }
    8. return false;
    9. }
    To copy to clipboard, switch view to plain text mode 

    But what should we do to get mouse events on title bar in MAC.
    Any help?

  2. #2
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get mouse events in MAC

    Qt Code:
    1. bool RightSideBar::winEvent(MSG *msg, long *result)
    2. {
    3. bool retval = true;
    4.  
    5. switch (msg->message)
    6. {
    7.  
    8. case WM_NCLBUTTONDOWN:
    9. qDebug()<<"Using Windows API Button Down";
    10. break;
    11.  
    12. case WM_NCLBUTTONUP:
    13. qDebug()<<"Using Windows API Button UP";
    14.  
    15. break;
    16. default:
    17. retval = false;
    18. }
    19.  
    20. return retval;
    21. }
    To copy to clipboard, switch view to plain text mode 

    But here resize and widget move options are not working in our application.We also need the same event(winEvent) in MAC OS .Can anyone help us in this?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Get mouse events in MAC

    QWidget::macEvent() seems fairly obvious (or QApplication::macEventFilter() for earlier Qt versions). Once you abandon the platform independence of Qt you are much less likely to get responses in here.

    Your winEvent code returns true for these two events which will stop any further processing by Qt. Perhaps that is what is breaking the "resize and widget move options" you complain about.

  4. The following user says thank you to ChrisW67 for this useful post:

    vinayaka (27th January 2012)

  5. #4
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get mouse events in MAC

    we need to get the mouse up event on Application's Title bar in Windows and MAC OS.In window we got the solution,but in MAC we don't know how to get mouse up event on Title bar.
    Qt Code:
    1. //Function for getting Mouse Event on TitleBar in Windows.
    2.  
    3. #ifdef Q_OS_WIN
    4. bool RightSideBar::winEvent(MSG *msg, long *result)//This function working fine in our application
    5. {
    6.  
    7. switch (msg->message)
    8. {
    9.  
    10. case 562:
    11. {
    12. qDebug()<<"Using Windows API Mouse Button UP"<<msg->message;
    13. return false;
    14. break;
    15. }
    16.  
    17.  
    18. }
    19.  
    20. return false;
    21. }
    22. #endif
    23. //End Function for getting Mouse Event on TitleBar in Windows.
    24.  
    25.  
    26. //Function for getting Mouse Event on TitleBar in MAC.
    27. #ifdef Q_OS_MAC
    28. bool RightSideBar::macEvent(EventHandlerCallRef caller, EventRef event)
    29. {
    30. qDebug()<<"Inside MAC event.....";//we dont know how to get mouse event here
    31. return false;
    32. }
    33. #endif
    To copy to clipboard, switch view to plain text mode 

    please help us..
    Last edited by vinayaka; 31st January 2012 at 07:11.

  6. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Get mouse events in MAC

    I Googled the docs for you: Cocoa Event-Handling Guide: Handling Mouse Events. This is nothing to do with Qt.

    The process probably goes something like this:
    • Use EventRef to get NSEvent *
    • Use NSEvent to check event type and get relevant mouse information

    How you do that from C++ I don't know.

  7. The following user says thank you to ChrisW67 for this useful post:

    vinayaka (31st January 2012)

Similar Threads

  1. Replies: 3
    Last Post: 8th October 2011, 10:46
  2. Mouse events
    By Maluko_Da_Tola in forum Newbie
    Replies: 3
    Last Post: 25th August 2010, 07:55
  3. Mouse Events
    By daviddoria in forum Qt Programming
    Replies: 6
    Last Post: 13th May 2008, 12:55
  4. mouse events
    By xyzt in forum Newbie
    Replies: 3
    Last Post: 23rd March 2008, 12:14
  5. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 07:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.