/// <summary> /// Handles the button press event to track which focused menu item will get the activation /// </summary> /// <param name="backButton"></param> /// <param name="startButton"></param> /// <param name="systemButton"></param> /// <param name="aButton"></param> /// <param name="bButton"></param> /// <param name="xButton"></param> /// <param name="yButton"></param> /// <param name="leftShoulder"></param> /// <param name="rightShoulder"></param> /// <param name="player"></param> protected override void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { base.OnGamePadButtonUpdate(backButton, startButton, systemButton, aButton, bButton, xButton, yButton, leftShoulder, rightShoulder, player); if (!HasFocus) { return; } if (backButton == CCGamePadButtonStatus.Pressed || aButton == CCGamePadButtonStatus.Pressed || bButton == CCGamePadButtonStatus.Pressed || xButton == CCGamePadButtonStatus.Pressed || yButton == CCGamePadButtonStatus.Pressed || leftShoulder == CCGamePadButtonStatus.Pressed || rightShoulder == CCGamePadButtonStatus.Pressed) { CCMenuItem item = FocusedItem; item.Selected(); m_pSelectedItem = item; m_eState = CCMenuState.TrackingTouch; } else if (backButton == CCGamePadButtonStatus.Released || aButton == CCGamePadButtonStatus.Released || bButton == CCGamePadButtonStatus.Released || xButton == CCGamePadButtonStatus.Released || yButton == CCGamePadButtonStatus.Released || leftShoulder == CCGamePadButtonStatus.Released || rightShoulder == CCGamePadButtonStatus.Released) { if (m_eState == CCMenuState.TrackingTouch) { // Now we are selecting the menu item CCMenuItem item = FocusedItem; if (item != null && m_pSelectedItem == item) { // Activate this item item.Unselected(); item.Activate(); m_eState = CCMenuState.Waiting; m_pSelectedItem = null; } } } }
public override void TouchEnded(CCTouch touch) { Debug.Assert(m_eState == CCMenuState.TrackingTouch, "[Menu TouchEnded] -- invalid state"); if (m_pSelectedItem != null) { m_pSelectedItem.Unselected(); m_pSelectedItem.Activate(); } m_eState = CCMenuState.Waiting; }