Results 1 to 7 of 7

Thread: Subscribe to Mac OS keypress event

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2017
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Subscribe to Mac OS keypress event

    thanks for the feedback ChrisW67. I thought maybe the CocoaNativeEventFilter::nativeEventFilter() was implemented <Appkit.h>, updated that and getting other compile errors now...

    But my main question is how I can detect keypress events when my application is not in focus, is this possible with Qt?

    thank you

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Subscribe to Mac OS keypress event

    Quote Originally Posted by felli View Post
    But my main question is how I can detect key press events when my application is not in focus, is this possible with Qt?
    It is not really a Qt question: Qt deals with the key presses the operating system sends it when it has focus. The question is whether the OS gives you a way to intercept key presses regardless of where they would naturally flow.

    NSEvent addGlobalMonitorForEvents() looks promising to turn on a capture:
    https://developer.apple.com/document...nitorforevents
    Exactly how you access this in your C++ code is not something I am familiar with although I expect that the resulting events should be seen in the Qt event filter.

  3. #3
    Join Date
    May 2017
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Subscribe to Mac OS keypress event

    Quote Originally Posted by ChrisW67 View Post
    It is not really a Qt question: Qt deals with the key presses the operating system sends it when it has focus. The question is whether the OS gives you a way to intercept key presses regardless of where they would naturally flow.

    NSEvent addGlobalMonitorForEvents() looks promising to turn on a capture:
    https://developer.apple.com/document...nitorforevents
    Exactly how you access this in your C++ code is not something I am familiar with although I expect that the resulting events should be seen in the Qt event filter.
    Thank you ChrisW67, just the answer I needed. I will look into that.

Similar Threads

  1. TableView keypress event
    By yur0k in forum Newbie
    Replies: 2
    Last Post: 7th October 2020, 19:54
  2. probelm in keypress event
    By iswaryasenthilkumar in forum Newbie
    Replies: 2
    Last Post: 7th April 2015, 07:51
  3. QDialog keypress event
    By bear35645 in forum Qt Programming
    Replies: 6
    Last Post: 6th February 2015, 06:51
  4. how to combine keypress event and mousebuttonpress event?
    By hildebrand in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2009, 23:08
  5. keypress event
    By vishesh in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2007, 14:12

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.