Results 1 to 3 of 3

Thread: Keyboard and Mouse focus when having several windows...

  1. #1
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Keyboard and Mouse focus when having several windows...

    Hi!
    The thing is that I don't really understand how to handle the keyboard and mouse. I think this is reffered as focus or something...

    My program consists of a main window containing a 3d scene. The user can open other windows that displays information about the scene and selected components of it. No of the windows is set to modal ( no window freeze the others ) or what it's called.

    If the user have opened on of the additional windows, we'll call it window A and has the main window, window M, in focus there are no problem when handling keyboard and mouse input. M takes both the mouse and keyboard. But if I have A in focus and I then want to spin the scene in the M window by holding down Ctrl and drag the mouse over it, the Ctrl is catched by the A window ( which also uses it ) and only the mouse is catched by M.

    Whats happeing is that when I move the mouse over to the M window and pressing Ctrl , the A window catches that and then when the mouse is dragged over the M window it can't register any Ctrl pressed... because A has already taken care of it, in the wrong way.

    So I wonder if there is any way to let the Window that lies under the current position of the mouse also catch the keyboard input, or something similar? Maybe that solution would lead to some other anyoing things... like if I want to type text in a window but places the mouse pointer over another window after selecting the textfield which is supposed to be filled...

    Or do I need some kind of administrator interpreting the combinations of events that is sent from the mouse and keyboard. If so, how do I implement something like that?

    thanks for reading
    pir

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keyboard and Mouse focus when having several windows...

    You can proabably use enterEvent() and leaveEvent() and set the focus of your widgets accordingly.

  3. #3
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Keyboard and Mouse focus when having several windows...

    Yes, that seems like something to start with. But there are some problems with how to interpret the events. The problem is that there can be more than one window that can accept a Ctrl key. I have a tree view of the object in one window and the 3d scene in the other. If I hold down Ctrl and drag my mouse around the 3d scene window, it results in turning the camera. But if I selects items in the tree view with the Ctrl key pressed several items is selected.

    So if I press the Ctrl key and move the mouse to the 3d scene, it should know that the Ctrl is pressed down. But it's pressed down before the mouse have reached the window, so it will miss the event, because it's handeled by another window where it results in nothing... is there any way to see if the Ctrl key is held down in Qt or do I need to do this myself?

    thanks
    pir

Similar Threads

  1. Keyboard Handling
    By ToddAtWSU in forum Qt Programming
    Replies: 4
    Last Post: 5th July 2006, 14:25

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.