User Tag List

Results 1 to 9 of 9

Thread: Dangerous window focus bug in MMF2

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dangerous window focus bug in MMF2

    I've tested this with the HWA runtime. Put a large image (2000x2000 pixels or so) in a blank application just to make the loading time a bit slower (just like an actual game). Add some events "upon pressing key" or "repeat while key pressed" events that shows any feedback. Now start your application. I'm not sure exactly what the timing should be for it to happen, but if you click somewhere to focus on another window while the application is loading, the game will show up and appear to be on top. The key conditions will also trigger when you press the keys, BUT the application that actually has focus will also catch the keystrokes.

    This has been a repeatedly reported problem with my games, especially if the user has enabled "go directly into full screen", because they clicked somewhere while the game was loading, when they're done playing my game and closes it, it turns out another application has got every keystroke and which has caused a mess. This really needs to be fixed.

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Nifflas, I've experienced this with more than just MMF2-made applications.
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It can be fixed though. The Window Focus object always gets it right, so a workaround is always to check with that when getting input. I don't like workarounds like that tho but will use them if I have to. I just think this one is particularly important to fix because people will blame me if my game goes full screen and something in the background gets messed up.

  4. #4
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Actually I do remember James complaining before that Y/F were using some method of detecting keypresses that could, in certain accidental cases, detect them without focus. I'd have thought that'd be fixed by now...

  5. #5
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, it's because they're using GetKeyState instead of keyboard hooks IIRC. This is why I wrote the Keyboard object a few years back.

  6. #6
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    14,047
    Mentioned
    279 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Nifflas View Post
    It can be fixed though. The Window Focus object always gets it right, so a workaround is always to check with that when getting input. I don't like workarounds like that tho but will use them if I have to. I just think this one is particularly important to fix because people will blame me if my game goes full screen and something in the background gets messed up.
    Are you sure Nifflas? The Window Focus object (the one made by Cellosoft) checks if the window of the application is the active window using the GetActiveWindow function. The routine of the MMF2 runtime that checks the keyboard does exactly the same thing, so I don't see why this would work in the object and not in the runtime.

  7. #7
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    14,047
    Mentioned
    279 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by James View Post
    Yes, it's because they're using GetKeyState instead of keyboard hooks IIRC. This is why I wrote the Keyboard object a few years back.
    James, I tried to use a hook when you suggested it, this did not fix the problem, so I put back the original routine as this could cause other issues.

  8. #8
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure Nifflas? The Window Focus object (the one made by Cellosoft) checks if the window of the application is the active window using the GetActiveWindow function. The routine of the MMF2 runtime that checks the keyboard does exactly the same thing, so I don't see why this would work in the object and not in the runtime.
    Yeah, you're right. When testing more it turns out that object also got it wrong.

    I have no idea, maybe a solution is to re-focus the window when the MMF2 app is fully loaded?

  9. #9
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't experienced this before, but it's good to know about.

    In my current game I'm using the Key object to detect my controls and I have an event:
    "Windows has Focus" > Enable (Key Object)
    as well as
    "[X] Window has Focus" > Disable (Key Object)

    Which stops it getting keypresses when it doesn't have focus (as it normally would get the keypresses when it's alt-tabbed for example / in the background).

    So that might be another work around which could help.

Similar Threads

  1. Window in focus
    By Ls2 in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 16th September 2011, 09:53 PM
  2. Set window focus
    By Nick in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 8th September 2007, 11:19 PM
  3. How can you find and re-focus the previous window?
    By Simon in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 14th May 2007, 01:10 AM
  4. Simulating Keys without window Focus
    By Dines in forum Extension Development
    Replies: 8
    Last Post: 10th April 2007, 02:54 PM
  5. "Window has focus"
    By Patrick in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 28th September 2006, 06:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •