/** * De-registers an existing listener from receiving button events. * * @param listener to be removed. * @since v2.0 */ public void RemoveButtonListener(IButtonListener listener) { // Start logging elapsed time. long tIn = TimerUtil.CurrentTimeMillis(); ILogging logger = AppRegistryBridge.GetInstance().GetLoggingBridge(); if (logger != null) { logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "DeviceBridge executing removeButtonListener..."); } if (this._delegate != null) { this._delegate.RemoveButtonListener(listener); if (logger != null) { logger.Log(ILoggingLogLevel.Debug, this.apiGroup.ToString(), "DeviceBridge executed 'removeButtonListener' in " + (TimerUtil.CurrentTimeMillis() - tIn) + "ms."); } } else { if (logger != null) { logger.Log(ILoggingLogLevel.Error, this.apiGroup.ToString(), "DeviceBridge no delegate for 'removeButtonListener'."); } } }
/// <summary> /// Unsubscribe a given listener /// from the collection that it /// was assigned to /// </summary> /// <param name="listener">The listener to be removed</param> public void Unsubscribe(IButtonListener listener) { // Get the button(s) that the VRDControllerButtonListener // was getting input from OVRInput.Button targetButton = listener.TargetButton; // Check to see if each of our // buttons were being listened to. // When one is found, remove the // listener from the appropriate // collection if (targetButton.HasFlag(OVRInput.Button.One)) { Unsubscribe(listener, ref buttonOneListeners); } if (targetButton.HasFlag(OVRInput.Button.Two)) { Unsubscribe(listener, ref buttonTwoListeners); } if (targetButton.HasFlag(OVRInput.Button.PrimaryThumbstick)) { Unsubscribe(listener, ref thumbstickListeners); } if (targetButton.HasFlag(OVRInput.Button.PrimaryIndexTrigger)) { Unsubscribe(listener, ref indexTriggerListeners); } if (targetButton.HasFlag(OVRInput.Button.PrimaryHandTrigger)) { Unsubscribe(listener, ref gripTriggerListeners); } }
public void ReplaceButtonListener(IButtonListener newListener) { var index = GameComponentsLookup.ButtonListener; var component = CreateComponent <ButtonListenerComponent>(index); component.listener = newListener; ReplaceComponent(index, component); }
protected override void Awake() { base.Awake(); sellerViewController = viewContext.SellerViewController; playerLookController = modelContext.PlayerLookController; modelController = modelContext.ModelController; backListener = viewContext.BackButtonListener; }
/// <summary> /// This method is used to subscribe a /// VRDControllerButtonListener to an /// appropriate collection /// </summary> /// <param name="listener">The VRDControllerButtonListener /// will be receiving input feedback</param> /// <param name="targetList">The list of VRDControllerButtonListener /// components that this component should be assigned to</param> private void Subscribe(IButtonListener listener, ref List <IButtonListener> targetList) { // Check to see if the listener // is already in the list before adding if (!targetList.Contains(listener)) { // Add the listener to the // collection targetList.Add(listener); } }
/// <summary> /// Poistaa focuksen kontrollilta ja sen mahdollisilta listenereitlä /// ja childeiltä. /// </summary> public virtual void Defocus() { IButtonListener buttonListener = this as IButtonListener; if (buttonListener != null) { buttonListener.ButtonEventListener.Trigger.CurrentState = PressedState.None; } hasFocus = false; }
// --- Interface methods --- public void AddButtonListener(IButtonListener buttonListener, int buttonID) { List <IButtonListener> value = null; if (Buttons.TryGetValue(buttonID, out value)) { value.Add(buttonListener); } else { List <IButtonListener> listenList = new List <IButtonListener>(); listenList.Add(buttonListener); Buttons.Add(buttonID, listenList); } }
/// <summary> /// This method is used to remove a /// VRDControllerButtonListener from an /// appropriate collection /// </summary> /// <param name="listener">The VRDControllerButtonListener /// will was receiving input feedback</param> /// <param name="targetList">The list of VRDControllerButtonListener /// components that this component should be removed from</param> public void Unsubscribe(IButtonListener listener, ref List <IButtonListener> targetList) { // Note that the method signature // above uses the ref keyword which // will allow us to manipulate the List // that is being used directly. // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref // Make sure the listener // is in the collection before // trying to remove it if (targetList.Contains(listener)) { // Remove the listener that was // found targetList.Remove(listener); } }
public void GenerateTextButtons(IButtonListener target, string[] buttonText, int[] buttonCodes) { GameManager.getInstance().TogglePlayerMovement(false); if (buttonText.Length == buttonCodes.Length) { textButtons = new List <Button>(); for (int i = 0; i < Mathf.Min(buttonText.Length, textButtonPositions.Length); i++) { /*IButton btn = textButtons[i]; * btn.gameObject.SetActive(true); * TextButton txt = btn.gameObject.GetComponent<TextButton>(); * txt.SetListener(target); * txt.SetText(buttonText[i]); * txt.SetButtonCode(buttonCodes[i]);*/ Button btn = textButtons[i]; btn.gameObject.SetActive(true); } } }
/// <summary> /// Tries to attach the given command input listener to the appropriate command button slot if the given listener is a command button /// listener, and the state of the given listener is not CommandButtonStateEnum.Invisible. /// </summary> /// <param name="listener">The command input listener to attach.</param> /// <remarks> /// If the given command input listener is not a command button listener, or its state is CommandButtonStateEnum.Invisible then this /// function has no effect. /// </remarks> private void TryAttachAsButtonListener(CommandInputListener listener) { IButtonListener buttonListener = listener as IButtonListener; if (buttonListener == null) { return; } AvailabilityEnum buttonAvailability = buttonListener.ButtonAvailability; if (buttonAvailability == AvailabilityEnum.Unavailable) { return; } RCIntVector slotPosition = buttonListener.CommandPanelSlot; if (this.commandPanelSlots[slotPosition.X, slotPosition.Y] != null) { if (this.commandPanelSlots[slotPosition.X, slotPosition.Y].ButtonListener.Priority > buttonListener.Priority) { /// Another IButtonListener with higher priority has already been attached to the command panel slot. return; } else if (this.commandPanelSlots[slotPosition.X, slotPosition.Y].ButtonListener.Priority == buttonListener.Priority) { throw new InvalidOperationException(string.Format("Another IButtonListener with the same priority has already been attached to command panel slot {0}!", slotPosition)); } } this.commandPanelSlots[slotPosition.X, slotPosition.Y] = new CommandPanelSlot { ButtonState = buttonAvailability == AvailabilityEnum.Disabled ? CommandButtonStateEnum.Disabled : CommandButtonStateEnum.Enabled, ButtonSprite = buttonListener.ButtonSprite, ButtonListener = buttonListener, Listener = listener }; }
public void SetListener(IButtonListener l) { listener = l; }
public void AddButtonListener(IButtonListener listener) { listeners.Add(listener); }
public void SetButtonListener(IButtonListener listener) { }
public void RemoveListener(IButtonListener buttonListener) { buttonListeners.Remove(buttonListener); }
public void RegisterListener(IButtonListener buttonListener) { buttonListeners.Add(buttonListener); }
public void RemoveListener(IButtonListener listener) { btn.onClick.RemoveListener(() => listener.ClickCallback()); }
/// <summary> /// Метод вызывает событие нажатие на нужную кнопку. /// </summary> /// <param name="btn"></param> public void ButtonPress(IButtonListener btn) { btn.ButtonPressed(); }
public void AddListener(IButtonListener listener) { _buttonListeners.Add(listener); }
protected override void Awake() { base.Awake(); modelController = modelContext.ModelController; backListener = viewContext.BackButtonListener; }
protected override void Awake() { base.Awake(); backListener = viewContext.BackButtonListener; }
public void SetButtonListener(IButtonListener listener) => _listener = listener;
public void AddListener(IButtonListener listener) { btn.onClick.AddListener(() => listener.ClickCallback()); }