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

Add Back press event to avoid double back to exit #5

Open
pazunino opened this issue May 10, 2021 · 0 comments
Open

Add Back press event to avoid double back to exit #5

pazunino opened this issue May 10, 2021 · 0 comments

Comments

@pazunino
Copy link

pazunino commented May 10, 2021

Hi,
because my app is used in the field press twice back to exit is not an option.
Based on this [https://stackoverflow.com/a/52366043], I added these piece of code to ExtendedEntry and ExtendedEntryRenderer.

In ExtendedEntry
public static readonly BindableProperty BackPressProperty=BindableProperty.Create("BackPress", typeof(EventHandler), typeof(ExtendedEntry), null); public event EventHandler BackPress; public bool OnBack() { EventHandler eventHandler = this.BackPress; eventHandler?.Invoke((object)this, EventArgs.Empty); return eventHandler != null; }

In ExtendedEntryRenderer
public override bool DispatchKeyEventPreIme(KeyEvent e) { if(!_softKeboardService.IsKeyboardVisible() && e.KeyCode == Keycode.Back) { if(Element != null && Element is ExtendedEntry) { if (((ExtendedEntry)Element).OnBack()); return true; } } return base.DispatchKeyEventPreIme(e); }
Then in the event handler you can put a Navigation action or a message.
If you consider this addition useful you can add it.
Regards,
Pedro.

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

1 participant