Results 1 to 8 of 8

Thread: MenuBar grabs the focus on ALT pressed.

  1. #1
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up MenuBar grabs the focus on ALT pressed.

    Hi Buddies,

    How do I prevent "MenuBar" from stealing the focus
    when the user presses the ALT - key?

    I just need under some circumstances *every* ALT - key press event to be received by the widget that has the focus without the focus being lost in between. Is it a Qt Bug?

    Note:
    I am using Qt 3.3.4 on Windows.
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MenuBar grabs the focus on ALT pressed.

    Quote Originally Posted by Cutey View Post
    Is it a Qt Bug?
    No, it's the operating system's behaviour Try using the other Alt key Remember you can always catch appropriate events by using an event filter or reimplementing event() to "steal" the key event before it is forwarded to the menu.

  3. #3
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MenuBar grabs the focus on ALT pressed.

    By simply pressing ALT Key, the focus is grabbed by the menubar in QMainWindow,
    but I dont want to handle the ALT pressed event in my widget. If I used eventfilter() for ALT pressed, this would block ShortCut functionalities too.

    Expected behavior is MenuBar should have focus only for Short Cut(ALT+f, ALT+E, & etc.,) functionality not for "every" ALT pressed.

    Any Suggestion ?! Thanks in Advance...
    Last edited by Cutey; 11th January 2007 at 10:05.
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MenuBar grabs the focus on ALT pressed.

    Ask Microsoft to change the system's behaviour

    And seriously - if you simply stop the event from being forwarded to the menu, it doesn't mean that shortcuts will seize working. The state of the alt key will still be caried in the keyEvent for the shortcut trigger. At least in theory

    BTW. I think an event filter won't (or may not) be enough here - you may have to reimplement event() for the widget or even for the application object.

  5. #5
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MenuBar grabs the focus on ALT pressed.

    Okey,

    I have one more problem related with ALT Key.

    In my application whereby the Alt key is supposed to be pressed to
    enable display of underlined characters in Menu Bar.

    Preferred behavior is for underlined letters which signify hot keys to be
    visible at all times independent of ALT key pressed.

    Is there any solution for this issue.?!
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MenuBar grabs the focus on ALT pressed.

    Quote Originally Posted by Cutey View Post
    Preferred behavior is for underlined letters which signify hot keys to be
    visible at all times independent of ALT key pressed.
    Configure your windows to show them. In "display" properties there's a "Appearance" tab with "Effects" button (the actual names might be different, because I have a Polish version).

  7. #7
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MenuBar grabs the focus on ALT pressed.

    Hi Jacek,

    Thanks for your valuable suggestion.

    Quote Originally Posted by jacek View Post
    Configure your windows to show them. In "display" properties there's a "Appearance" tab with "Effects" button.
    But I would like to do it by the code.
    For Example, In VC++ main window MenuBar you can see the underlined letters which signify hot keys visible at all times independent of the above property change.!!
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MenuBar grabs the focus on ALT pressed.

    Quote Originally Posted by Cutey View Post
    For Example, In VC++ main window MenuBar you can see the underlined letters which signify hot keys visible at all times independent of the above property change.!!
    It only means that it is badly implemented as it tries to be smarter than the user who should know whether he likes/wants the behaviour or not. You should think twice before trying to be too smart too.

    If you insist on implementing such behaviour, you'll have to subclass QMenu and do the highlighting yourself.

Similar Threads

  1. Tab/Enter focus problem
    By b1 in forum Qt Programming
    Replies: 4
    Last Post: 23rd October 2006, 23: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.