Botón#
Los objetos en los atributos ‘button’
| Controlador IQ (1.ª generación) | | :—————- | :—————–| |
ButtonEUp
- El botón E superior.ButtonEDown
- El botón E inferior.ButtonFUp
- El botón F superior.ButtonFDown
- El botón F inferior.ButtonLUp
- El botón L superior.ButtonLDown
- El botón L inferior.ButtonRUp
- El botón R superior.ButtonRDown
- El botón R inferior. |
apretado()#
El método pressed(callback)
registra una función que se llamará cuando se presione un botón.
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()#
El método released(callback)
registra una función que se llamará cuando se suelte un botón.
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()#
El método pressing()
devuelve si un botón está siendo presionado actualmente.
Devuelve: true
si el botón está siendo presionado actualmente. false
si no está siendo presionado actualmente.