Results 1 to 3 of 3

Thread: Capslock status

  1. #1
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Post Capslock status

    How can i get the status of capslock?
    is there any function in Qt to get this??

  2. #2
    Join Date
    Aug 2011
    Posts
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Capslock status

    bool checkCapsLock()
    {
    // platform dependent method of determining if CAPS LOCK is on
    #ifdef Q_OS_WIN32 // MS Windows version
    return GetKeyState(VK_CAPITAL) == 1;
    #else // X11 version (Linux/Unix/Mac OS X/etc...)
    Display * d = XOpenDisplay((char*)0);
    bool caps_state = false;
    if (d)
    {
    unsigned n;
    XkbGetIndicatorState(d, XkbUseCoreKbd, &n);
    caps_state = (n & 0x01) == 1;
    }
    return caps_state;
    #endif
    }

  3. The following user says thank you to cplus for this useful post:

    deepal_de (15th August 2011)

  4. #3

    Default Re: Capslock status

    Am I correct in assuming that if

    caps_state = (n & 0x01) == 1;

    will give me the state of the caps lock, that to find num, scroll, and kana lock i need to just do:

    num_state = (n & 0x02) == 2;
    scroll_state = (n & 0x04) == 4;
    kana_state = (n & 0x08) == 8;

    Is this correct? I have verified that this will work for number lock and that it *should* work for scroll lock, but i have no clue about kana lock. I have the bitwise masks for them being

    caps_lock = $ffe5
    num_lock = $ff7f
    scroll_lock = $ff14
    kana_lock = $ff2d

    but i dont see how this is helpful in determining their current states. Is there somewhere that I can find the appropriate masks for these as it pertains to XkbGetIndicatorState???

Similar Threads

  1. how to determine if CapsLock is on [crossplatform]
    By papius_vtualetius in forum Qt Programming
    Replies: 4
    Last Post: 7th September 2011, 21:16
  2. The CapsLock key of virtual keyboard doesn't work on QTE4.5
    By Babylon3389 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th October 2010, 13:50
  3. Replies: 3
    Last Post: 8th July 2010, 07:41
  4. Status Bar
    By waynew in forum Newbie
    Replies: 3
    Last Post: 21st November 2009, 09:07
  5. need help with the status bar
    By filmfreak in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2006, 08:34

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.