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

Added ability to pass callback as key trigger parameter. #13538

Merged

Conversation

reimund
Copy link
Contributor

@reimund reimund commented Feb 15, 2023

This PR makes it possible to add key up/down triggers with more control than using just lowercase letters, by allowing the use of a callback function as 'parameter' value.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 15, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 15, 2023

@reimund reimund force-pushed the feature/key-trigger-parameter-callback branch from 8f8b3bc to 3d88efc Compare February 15, 2023 10:35
@reimund
Copy link
Contributor Author

reimund commented Feb 15, 2023

This should be labeled with new feature but I do not think I have the rights to add labels.

@reimund
Copy link
Contributor Author

reimund commented Feb 15, 2023

Here's an example how this PR makes it possible to create a trigger that only triggers on uppercase R:

scene.actionManager.registerAction(
    new BABYLON.ExecuteCodeAction(
        {
            trigger: BABYLON.ActionManager.OnKeyUpTrigger,
            parameter: function(actionEvent) { return actionEvent.sourceEvent.key === 'R'; }
        },
        function () { console.log('R button was pressed'); }
    )
);

Copy link
Member

@RaananW RaananW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a great addition!

@RaananW
Copy link
Member

RaananW commented Feb 15, 2023

After this is merged - it would be great to expand this section of the docs:

https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants