Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Input Keys - BACK and MENU buttons #2218

Closed
DrDerico opened this issue May 2, 2019 · 4 comments
Closed

Android Input Keys - BACK and MENU buttons #2218

DrDerico opened this issue May 2, 2019 · 4 comments

Comments

@DrDerico
Copy link

DrDerico commented May 2, 2019

  • Haxe version: 3.4.7
  • Flixel version: 4.6.1
  • OpenFL version: 8.9.0
  • Lime version: 7.3.0
  • Affected targets: Android

1.
Finally I moved from OpenFL 3.6.1 and Flixel 3.3.5 to the latest versions. And BANG! On Android the BACK button stops to work the way as it worked before.

I used FlxG.android.preventDefaultKeys(27) in my code.

So, after a big investigation I found where the problem was. In Lime 7.3.0 (and in the earlier versions) android codes for BACK button are changed from "27" (decimal) to "var APP_CONTROL_BACK = 0x4000010E;" and code of MENU button from "16777234" (decimal) to "var APP_CONTROL_SEARCH = 0x4000010C; ".

I made changes on my side in flixel/input/android/FlxAndroidKeys.hx and flixel/input/android/FlxAndroidKey.hx by replacing old values to the new ones and it starts to work!

2.
I found that in

function handlePreventDefaultKeys(keyCode:Int, event:KeyboardEvent):Void
preventDefault is used only for #html5 target. But why???? Where is #android???

I suggest to add #android also, because whithout that BACK button event doesn't prevented on Android.

Code snippet:

#if (html5 || android)
	event.preventDefault();
#end

Sorry for English

@DrDerico
Copy link
Author

DrDerico commented May 6, 2019

Thank you!

@DrDerico DrDerico closed this as completed May 6, 2019
@Tw1ddle
Copy link

Tw1ddle commented May 6, 2019

Thanks, perhaps @JoeCreates or someone could commit the fix to Flixel itself 😄

@Gama11 Gama11 reopened this May 6, 2019
@Gama11
Copy link
Member

Gama11 commented May 6, 2019

@Tw1ddle Why not just open a PR yourself? ;)

I think we want to have conditionals for old OpenFL versions / the old values though, we haven't dropped OpenFL 3.6.1 support yet.

@Gama11 Gama11 added the Bug label Jun 17, 2019
@Gama11 Gama11 closed this as completed in 4e67c26 Jun 17, 2019
@Gama11
Copy link
Member

Gama11 commented Jun 17, 2019

Thanks for the investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants