public override void _Input(InputEvent _event) { var method = _event.InputMethod(); if (method == InputMethod.None) { return; } if (method != InputMethod.None && method != CurrentInputMethod) { CurrentInputMethod = method; if (IsVisibleInTree()) { InitializeKeybindings(); } } if (ActionWaitingForInput != null) { GetNode <Control>(keybindingPopupPath).Hide(); KeybindingElement element = GetKeybingingElement(ActionWaitingForInput); InputMap.ActionEraseEvent(ActionWaitingForInput, element.InputEvent); InputMap.ActionAddEvent(ActionWaitingForInput, _event); element.InputEvent = _event; ActionWaitingForInput = null; } }
void InitializeKeybindings() { foreach (Node node in buttonContainer.GetChildren()) { node.QueueFree(); } foreach (string action in InputMap.GetActions()) { if (SkipUiActions && action.StartsWith("ui_")) { continue; } if (SkipDebugActions && action.StartsWith("debug_")) { continue; } KeybindingElement element = (KeybindingElement)keybindingElement.Instance(); buttonContainer.AddChild(element); element.Action = action; foreach (InputEvent _event in InputMap.GetActionList(action)) { if (_event.MatchInputMethod(CurrentInputMethod)) { element.InputEvent = _event; break; } //Debug } element.ConnectPressed(this, nameof(GetNewInput), element.Action.InArray()); } }