Botón#
The objects in the button
attributes
| IQ (1st gen) Controller | | :—————- | :—————–| |
ButtonEUp
- The Upper E button.ButtonEDown
- The Lower E button.ButtonFUp
- The Upper F button.ButtonFDown
-The Lower F button.ButtonLUp
- The Upper L Button.ButtonLDown
- The Lower L Button.ButtonRUp
- The Upper R Button.ButtonRDown
- The Lower R Button. |
apretado()#
The pressed(callback)
method registers a function to be called when a button is pressed.
Parámetro |
Descripción |
---|---|
llamar de vuelta |
Una función que se llamará cuando se presione el botón. |
Devoluciones: Ninguna.
// Define the buttonPressed function with a void return
// type, showing it doesn't return a value.
void buttonPressed() {
// The Brain will print that a controller button was
// pressed on the Brain's screen.
Brain.Screen.print("controller button pressed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run buttonPressed when the Left Up button is pressed
// on the controller.
Controller.ButtonLUp.pressed(buttonPressed);
}
liberado()#
The released(callback)
method registers a function to be called when a button is released.
Parámetro |
Descripción |
---|---|
llamar de vuelta |
Una función que se llamará cuando se suelte el botón. |
Devoluciones: Ninguna.
// Define the buttonReleased function with a void return
// type, showing it doesn't return a value.
void buttonReleased() {
// The Brain will print that a controller button was
// released on the Brain's screen.
Brain.Screen.print("controller button released");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run buttonReleased when the Left Up button is released
// on the controller.
Controller.ButtonLUp.released(buttonReleased);
}
prensado()#
The pressing()
method returns whether a button is currently being pressed.
Returns: true
if the button is currently being pressed. false
if it is not currently being pressed.