zduny
zduny

Reputation: 2541

OpenTK GameWindow in fullscreen - handle OS shortcuts

I noticed that if you change your GameWindow state to Fullscreen you can no longer use system keyboard shortcuts like Alt+F4 or Alt+Tab (they simply do nothing, BTW I use Windows 7).

Is there a way to fix it? Do I have to catch this shortcuts manually in my application (and trigger appropriate action)?

Upvotes: 1

Views: 791

Answers (1)

Noah Heber
Noah Heber

Reputation: 82

I realize this is an old question, but I'm posting the answer for anyone Googling this like I did.

You will have to manually register the OnKeyDown event.

protected override void OnKeyDown(KeyboardKeyEventArgs e)
{
    base.OnKeyDown(e);
    if (e.Alt && e.Key == Key.F4)
    {
        Environment.Exit(0);
    }
}

This worked for me. If you want it to bring up an "Are you sure?" message or something like that, you can put it in the if statement.

Upvotes: 1

Related Questions