@@ -1816,22 +1816,42 @@ public boolean dispatchKeyEvent(KeyEvent event) {
18161816
18171817 @ Override
18181818 public boolean dispatchKeyShortcutEvent (KeyEvent ev ) {
1819- // Perform the shortcut (mPreparedPanel can be null since
1820- // global shortcuts (such as search) don't rely on a
1821- // prepared panel or menu).
1822- boolean handled = performPanelShortcut (mPreparedPanel , ev .getKeyCode (), ev ,
1823- Menu .FLAG_PERFORM_NO_CLOSE );
1824- if (handled ) {
1825- if (mPreparedPanel != null ) {
1826- mPreparedPanel .isHandled = true ;
1819+ // If the panel is already prepared, then perform the shortcut using it.
1820+ boolean handled ;
1821+ if (mPreparedPanel != null ) {
1822+ handled = performPanelShortcut (mPreparedPanel , ev .getKeyCode (), ev ,
1823+ Menu .FLAG_PERFORM_NO_CLOSE );
1824+ if (handled ) {
1825+ if (mPreparedPanel != null ) {
1826+ mPreparedPanel .isHandled = true ;
1827+ }
1828+ return true ;
18271829 }
1828- return true ;
18291830 }
18301831
18311832 // Shortcut not handled by the panel. Dispatch to the view hierarchy.
18321833 final Callback cb = getCallback ();
1833- return cb != null && !isDestroyed () && mFeatureId < 0 ? cb .dispatchKeyShortcutEvent (ev )
1834- : super .dispatchKeyShortcutEvent (ev );
1834+ handled = cb != null && !isDestroyed () && mFeatureId < 0
1835+ ? cb .dispatchKeyShortcutEvent (ev ) : super .dispatchKeyShortcutEvent (ev );
1836+ if (handled ) {
1837+ return true ;
1838+ }
1839+
1840+ // If the panel is not prepared, then we may be trying to handle a shortcut key
1841+ // combination such as Control+C. Temporarily prepare the panel then mark it
1842+ // unprepared again when finished to ensure that the panel will again be prepared
1843+ // the next time it is shown for real.
1844+ if (mPreparedPanel == null ) {
1845+ PanelFeatureState st = getPanelState (FEATURE_OPTIONS_PANEL , true );
1846+ preparePanel (st , ev );
1847+ handled = performPanelShortcut (st , ev .getKeyCode (), ev ,
1848+ Menu .FLAG_PERFORM_NO_CLOSE );
1849+ st .isPrepared = false ;
1850+ if (handled ) {
1851+ return true ;
1852+ }
1853+ }
1854+ return false ;
18351855 }
18361856
18371857 @ Override
0 commit comments