Error when creating buttons

Hi there, we are having a couple errors when coding joystick buttons on the xbox controller. in the line of code
new JoystickButton(operator, Button.kB.value)

    .whileHeld(() -> grabber.grabberBall(Constants.GRABBER_SPEED), grabber)

    .whenReleased(() -> grabber.grabberBall(0), grabber);

The errors are on .whileHeld and the rest of the line. The error messages read “The method whileHeld(Command) in the type Button is not applicable for the arguments (() → {}, Elevator)Java(67108979)” , and “The target type of this expression must be a functional interfaceJava(553648781)”
Any help with fixing these errors would be greatly appreciated!

I had this problem (or at least a similar problem) earlier in the season. Check your button import and make sure that it’s the wpilibj2 import and not the wpilibj import.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.