Results 1 to 5 of 5

Thread: how to determine if CapsLock is on [crossplatform]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to determine if CapsLock is on [crossplatform]

    Hi, I've a similar problem. I need to check which is the physical modifiers' positions, Control, Shift and Alt. On Windows I did it handling the winEvents I'm trying to do the same in linunx handling the x11events but I can't check if the current XEvent is a KeyPress event. One of the problems is what you mentioned, I needed to undef the X11 KeyPress macro. I have tried to compare the XEvent type with 2 because this is the constant declared in X11/X.h but didn't work.
    Qt Code:
    1. maiko@cits-d530:~/Projetos/Positivo$ grep -i keypress /usr/include/X11/X.h
    2. #define KeyPressMask (1L<<0)
    3. #define KeyPress 2
    To copy to clipboard, switch view to plain text mode 
    this is my current code
    Qt Code:
    1. bool MainWindow::x11Event(XEvent *xe)
    2. {
    3. //TODO: remove #undef KeyPress
    4. if(xe->type == 2)
    5. {
    6. switch (xe->xkey.keycode)
    7. {
    8. case 37://Control_L
    9. keyPressEvent(xe->xkey.keycode, "Key_ControlL");
    10. break;
    11. case 105://Control_R
    12. keyPressEvent(xe->xkey.keycode, "Key_ControlR");
    13. break;
    14. case 50://Shift_L
    15. keyPressEvent(xe->xkey.keycode, "Key_ShiftL");
    16. break;
    17. case 62://Shift_R
    18. keyPressEvent(xe->xkey.keycode, "Key_ShiftR");
    19. break;
    20. default:
    21. return false;
    22. }
    23. return true;
    24. }
    25. return false;
    26. }
    To copy to clipboard, switch view to plain text mode 

    Bye and thx.
    Last edited by MaikoID; 2nd May 2011 at 16:24.

Similar Threads

  1. Determine the Process ID
    By Jimmy2775 in forum General Programming
    Replies: 5
    Last Post: 7th October 2011, 09:16
  2. Replies: 0
    Last Post: 11th November 2009, 19:23
  3. Looking for a crossplatform library that works with zip archives
    By Berberis in forum General Programming
    Replies: 1
    Last Post: 10th March 2009, 07:06
  4. How to determine available memory
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2007, 00:00
  5. How to determine if my app is active...
    By Ben.Hines in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 16:02

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.