Hello,
I have following code:
[coed]
activators.Add(new ManipulatorActivationFilter { button = MouseButton.LeftMouse, modifiers = EventModifiers.Control | EventModifiers.Alt });
…
if (CanStartManipulation)
{
…
}
[/code]
If I press Control + click CanStartManipulation returns false. Looking into the source code manipulation check starts with alt and if it’s not pressed it returns false without checking other modifiers.
I thought EventModifiers.Control | EventModifiers.Alt means any of Control and Alt or both. But, apparently it is not.
Is it a bug or by design, or did I got it wrong?
Is there a way to specify any mouse button and/or any modifier?
Thanks.
Hi. EventModifiers are enum flags, so the | operator acts as a concatenator on them. In your code, modifiers = EventModifiers.Control | EventModifiers.Alt means you want both modifiers to be present.
The way Manipulator filters work, each filter is checking that all their requirements are met, but there can be multiple filters at once. The CanStartManipulation method will return true if any of the filter check passes. If you want the check to pass for either Control or Alt, you can add 2 ManipulatorActivationFilters, one with Control and one with Alt. As for any mouse button, I’m afraid you have to add all combinations of filters here also, which in your case would mean a total of 6.
I agree that this can be a bit tedious though. If you’re currently using a Clickable.clicked, you might consider using RegisterCallback<ClickEvent> instead, where you should receive the event for any mouse button and modifier combination, and you can filter them manually in your callback instead.
Thank you for clarification.