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

[Mobile] Add back button handling #2910

Closed
Koumbaya opened this issue Apr 11, 2022 · 5 comments
Closed

[Mobile] Add back button handling #2910

Koumbaya opened this issue Apr 11, 2022 · 5 comments
Assignees
Labels
blocker Items that would block a forthcoming release enhancement New feature or request

Comments

@Koumbaya
Copy link

Is your feature request related to a problem? Please describe:

On Android, to my knowledge the back button isn't "caught" as a keyboard event, and always quit (minimize) the app.
This prevent us for building "proper" apps where Back can be used to quit a submenu / go to the previous screen.

Is it possible to construct a solution with the existing API?

I'm not sure if just adding a KeyEvent (how ?) would be enough or if it is rooted deeper.
I don't think the other 2 buttons (recent-app & home) need handling because their use is identical whatever the app is running on screen and the OS probably lock them. There is also historically the "menu" button but it's not really used anymore I don't think it matters.
If someone have an idea I could take a shot at it.

Describe the solution you'd like to see:

I'm not sure if handling it as a key Event is the best option or goes well with the guidelines ?
But I think it is absolutely essential we can at least block the behavior of "back button > exit the app", even better handle it. I've made an app for someone, their biggest annoyance is pressing the back button to exit a window/form (as would be normal in any app) and have the whole app minimized.

@andydotxyz
Copy link
Member

But I think it is absolutely essential we can at least block the behavior of "back button > exit the app"

I don't think we can block it - exiting the app must be allowed, to go to previous app etc. However:

their biggest annoyance is pressing the back button to exit a window/form (as would be normal in any app) and have the whole app minimized.

Yes It could be good to implement the default so with multiple windows it hides the top one and goes back a level.

Further items would be interesting to explore, but as we don't have a navigation system in place yet it is hard to determine how that should work.

@andydotxyz andydotxyz added the enhancement New feature or request label Apr 11, 2022
@MatejMagat305
Copy link
Contributor

MatejMagat305 commented Apr 12, 2022

I m not expert, but I found two link:

https://gist.github.com/jrgleason/6089568 (mainly rows 58+)

https://stackoverflow.com/questions/12130618/android-ndk-how-to-override-onbackpressed-in-nativeactivity-without-java

and according documentation it look like that, after that it will pooling with key code....

@dweymouth
Copy link
Contributor

dweymouth commented Feb 2, 2023

But I think it is absolutely essential we can at least block the behavior of "back button > exit the app"

I don't think we can block it - exiting the app must be allowed, to go to previous app etc. However:

their biggest annoyance is pressing the back button to exit a window/form (as would be normal in any app) and have the whole app minimized.

Yes It could be good to implement the default so with multiple windows it hides the top one and goes back a level.

Further items would be interesting to explore, but as we don't have a navigation system in place yet it is hard to determine how that should work.

I think exposing the ability for the Fyne app to capture the back button keyevent would be good enough for now - leave the default behavior to exit the Fyne app but if an app does handle its own navigation context, let it override the back button to go back a page. (side note it'd be nice to have an API to bind iOS's swipe-from-left, swipe-from-right gestures as well)

@andydotxyz
Copy link
Member

This is under way :) It's gonna be a little tough to figure the right API, but the technical challenges are overcome already!

@andydotxyz andydotxyz self-assigned this Jun 3, 2023
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jun 5, 2023
@andydotxyz andydotxyz added the blocker Items that would block a forthcoming release label Jul 21, 2023
@andydotxyz
Copy link
Member

That's in develop ready for v2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants