Alt + Enter shortcut for fullscreen not working properly?

Hello again.

So I am currently trying to develop a game using HaxeFlixel. I would like to have a keyboard shortcut such as “Alt + Enter” to switch the game to fullscreen mode.

Trouble is that it seems that either OpenFL or HaxeFlixel has this feature built-in, but it doesn’t seem to work right. I’ve commented out my custom code that switches to fullscreen when “Alt + Enter” is pressed. But when I press that shortcut, it still attempts to switch to fullscreen. But the problem is that it constantly switches back and forth while the Enter key is pressed, and whether you get fullscreen or not is entirely a function of when you release the Enter key.

Again, I’m not sure if this is an OpenFL issue or a Flixel issue, but if someone knows how to correct it I’d appreciate the help. Ideally I’d use the native functionality, but if that’s not working right I’d like to be able to disable the native functionality and just use my custom logic to flip it to fullscreen. But I can’t seem to figure out how to do that either.

I’m targeting Linux, by the way, if that helps. Thanks for any help you can provide!

It may be helpful to try a small OpenFL sample. Use openfl create DisplayingABitmap (for example) and try Alt + Enter on the sample :slight_smile:

I did something like that a few minutes ago. I went back to a previous OpenFL project I was working on before I tried HaxeFlixel and tried Alt + Enter there. Same problem. So it doesn’t seem to be a HaxeFlixel issue. I also investigated whether it could be something with the window manager and came up with nothing.

Have you tried the latest OpenFL and Lime versions (compared to the old ones Flixel uses), to know if this is a current issue? What distribution, version and window manager are you running currently?

Thank you :slight_smile:

Ok, so I just tried my old project, which used to compile just fine, using Lime 3.5.2 and OpenFL 4.5.2. Now it won’t even compile. Gives me a very long error message, but it starts with:

/usr/share/haxe/std/neko/_std/EReg.hx:33: characters 11-61 : Unsupported escaped char 's'
<builtin>:1: character 0 : Called from...

and the rest of the message seems to be related to that, just a bunch of “Called from” messages.

So, I don’t know what’s going on anymore. I’m running Xfce on Debian Stretch, if that helps.

Ok, here’s an update. I went and got the latest Haxe version (3.4.0-rc.2) and now I can compile again. (This was fun because it isn’t in the Debian repository and I had to figure out where to put all the files for Haxelib and Lime to be able to find them, but I digress…)

The Alt + Enter thing is still an issue though. Like I said, it just continually switches between fullscreen and windowed while those keys are held. I have not figured out how to bypass this behavior, which seeing as I’m using Flixel, even if this is corrected in a later OpenFL version I’ll still need a fix while I’m using the old stuff.

OK, this is probably due to repeating key down events

We probably need to do a “toggleFullscreen” boolean value that clears only when KEY_UP (of some kind) is received, to prevent repeated fullscreen changes while you hold the keys down

Ah, that would be it then.

Right now I’m using Ctrl + Enter to toggle fullscreen in my game (separate from the Alt + Enter combination), and I did set a latch that clears on a KEY_UP event to keep it from doing that:

private function keyDown(event:KeyboardEvent)
    {
        if(event.keyCode == 13)
        {
            if(keyEnterLatchFalse == false)
                keyEnterPressed = true;

            keyEnterLatchFalse = true;
        }
        
        if(event.keyCode == 17)
            keyCtrl = true;
    }

    private function keyUp(event:KeyboardEvent)
    {
        if(event.keyCode == 13)
        {
            keyEnterPressed = false;
            keyEnterLatchFalse = false;
        }

        if(event.keyCode == 17)
            keyCtrl = false;
    }

So something like that should do the trick. If I modify NativeApplication.hx in the Haxelib folder that should carry over into my build, right?

For current OpenFL releases, yes. The old OpenFL (that HaxeFlixel uses) works differently :slight_smile:

Wow. So it looks like I’m really out of options until the Flixel folks get their stuff working with current OpenFL releases. :frowning:

Found it, looks like it’s here:

Awesome! I just commented out that section, and it went away! So that can be modified. Thanks for your help sir. :grinning:

Thanks for bringing this to my attention, its fixed now :slight_smile: