Improve toggle fullscreen

This commit is contained in:
Joshua Granick
2016-12-27 13:06:01 -08:00
parent 6b4f70027f
commit 4956adc595
2 changed files with 44 additions and 6 deletions

View File

@@ -66,12 +66,14 @@ class NativeApplication {
private var frameRate:Float; private var frameRate:Float;
private var parent:Application; private var parent:Application;
private var toggleFullscreen:Bool;
public function new (parent:Application):Void { public function new (parent:Application):Void {
this.parent = parent; this.parent = parent;
frameRate = 60; frameRate = 60;
toggleFullscreen = true;
#if (lime_console && final) #if (lime_console && final)
// suppress traces in final builds // suppress traces in final builds
@@ -302,20 +304,56 @@ class NativeApplication {
#if (windows || linux) #if (windows || linux)
if (keyCode == RETURN && (modifier == KeyModifier.LEFT_ALT || modifier == KeyModifier.RIGHT_ALT) && type == KEY_DOWN && !window.onKeyDown.canceled) { if (keyCode == RETURN) {
if (type == KEY_DOWN) {
if (toggleFullscreen && modifier.altKey && (!modifier.ctrlKey && !modifier.shiftKey && !modifier.metaKey)) {
toggleFullscreen = false;
if (!window.onKeyDown.canceled) {
window.fullscreen = !window.fullscreen; window.fullscreen = !window.fullscreen;
} }
}
} else {
toggleFullscreen = true;
}
}
#elseif mac #elseif mac
if (keyCode == F && modifier.ctrlKey && modifier.metaKey && type == KEY_DOWN && !modifier.altKey && !modifier.shiftKey && !window.onKeyDown.canceled) { if (keyCode == F) {
if (type == KEY_DOWN) {
if (toggleFullscreen && (modifier.ctrlKey && modifier.metaKey) && (!modifier.altKey && !modifier.shiftKey)) {
toggleFullscreen = false;
if (!window.onKeyDown.canceled) {
window.fullscreen = !window.fullscreen; window.fullscreen = !window.fullscreen;
} }
}
} else {
toggleFullscreen = true;
}
}
#elseif android #elseif android
if (keyCode == APP_CONTROL_BACK && modifier == KeyModifier.NONE && type == KEY_UP && !window.onKeyUp.canceled) { if (keyCode == APP_CONTROL_BACK && modifier == KeyModifier.NONE && type == KEY_UP && !window.onKeyUp.canceled) {

View File

@@ -29,7 +29,7 @@ namespace lime {
static void Dispatch (KeyEvent* event); static void Dispatch (KeyEvent* event);
double keyCode; double keyCode;
int modifier; uint16_t modifier;
KeyEventType type; KeyEventType type;
uint32_t windowID; uint32_t windowID;