コード例 #1
0
        private bool onContainerKey(android.view.KeyEvent @event)
        {
            int keyCode = @event.getKeyCode();

            if (isInterestingKey(keyCode))
            {
                if (keyCode == android.view.KeyEvent.KEYCODE_BACK)
                {
                    if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
                            () == 0)
                    {
                        if (mOwnerView != null)
                        {
                            android.view.KeyEvent.DispatcherState ds = mOwnerView.getKeyDispatcherState();
                            if (ds != null)
                            {
                                ds.startTracking(@event, this);
                            }
                        }
                        return(true);
                    }
                    else
                    {
                        if (@event.getAction() == android.view.KeyEvent.ACTION_UP && @event.isTracking() &&
                            [email protected]())
                        {
                            setVisible(false);
                            return(true);
                        }
                    }
                }
                else
                {
                    dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
                }
                // Let the container handle the key
                return(false);
            }
            else
            {
                android.view.ViewRootImpl viewRoot = getOwnerViewRootImpl();
                if (viewRoot != null)
                {
                    viewRoot.dispatchKey(@event);
                }
                // We gave the key to the owner, don't let the container handle this key
                return(true);
            }
        }
コード例 #2
0
 public virtual bool onKey(android.content.DialogInterface dialog, int keyCode, android.view.KeyEvent
                           @event)
 {
     if (keyCode == android.view.KeyEvent.KEYCODE_MENU || keyCode == android.view.KeyEvent
         .KEYCODE_BACK)
     {
         if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
                 () == 0)
         {
             android.view.Window win = mDialog.getWindow();
             if (win != null)
             {
                 android.view.View decor = win.getDecorView();
                 if (decor != null)
                 {
                     android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
                     if (ds != null)
                     {
                         ds.startTracking(@event, this);
                         return(true);
                     }
                 }
             }
         }
         else
         {
             if (@event.getAction() == android.view.KeyEvent.ACTION_UP && [email protected]())
             {
                 android.view.Window win = mDialog.getWindow();
                 if (win != null)
                 {
                     android.view.View decor = win.getDecorView();
                     if (decor != null)
                     {
                         android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
                         if (ds != null && ds.isTracking(@event))
                         {
                             mMenu.close(true);
                             dialog.dismiss();
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     // Menu shortcut matching
     return(mMenu.performShortcut(keyCode, @event, 0));
 }