Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Allow checking for exact matches with Action events. #50874

Merged
merged 1 commit into from
Jul 30, 2021

Commits on Jul 30, 2021

  1. Allow checking for exact matches with Action events.

    Added additional param to action related methods to test for exactness.
    If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
    
    Before:
    * Action Event = KEY_S
    * Input Event = KEY_CONTROL + KEY_S
    * Is Action Pressed = True
    
    Now:
    You can still do the above, however you can optionally check that the input is exactly what the action event is:
    * Action Event = KEY_S
    * Input Event = KEY_CONTROL + KEY_S
    * p_exact_match = True
    * Is Action Pressed = False
    * If the Input Event was only KEY_S, then the result would be true.
    
    Usage:
    
    ```gdscript
    Input.is_action_pressed(action_name: String, exact_match: bool)
    Input.is_action_pressed("my_action", true)
    
    InputMap.event_is_action(p_event, "my_action", true)
    
    func _input(event: InputEvent):
      event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
      event.is_action("my_action", true)
    ```
    
    Co-authored-by: Eric M <[email protected]>
    EricEzaM authored and raulsntos committed Jul 30, 2021
    Configuration menu
    Copy the full SHA
    0e5c6e0 View commit details
    Browse the repository at this point in the history