UrhoSharp 中的后退按钮没有响应

Back Button not Responding in UrhoSharp

我创建了一个 Activity,它的 UrhoSharp 表面为;

SDLSurface surface = UrhoSurface.CreateSurface(this, typeof(UrhoLayer), appOptions);

现在后退按钮没有响应。我尝试重写 onBackPressed(),但是当我按下后退按钮时不会调用此函数。如何使后退按钮起作用?

我通过在 DispatchKeyEvent 中捕捉后退按钮按下来解决这个问题。不是一个非常令人满意的解决方案,但它有效:

    public override bool DispatchKeyEvent(KeyEvent e)
    {
        if (e.Action == KeyEventActions.Up && e.KeyCode == Keycode.Back)
        {
            OnBackPressed();
            return true;
        }
        if (!UrhoSurface.DispatchKeyEvent(e))
            return false;
        return base.DispatchKeyEvent(e);
    }