Skip to content

⌨️ Navegación por Teclado y Accesibilidad

ParámetroEspecificación
Clase del ComponenteCollapsibleCategoryRuleEntry
Interfaz de Accesibilidadnet.minecraft.client.gui.narration.NarratableEntry
Prioridad de NarraciónNarrationPriority.HOVERED
Elemento NarradoNarratedElementType.TITLE
Teclas de AlternanciaGLFW_KEY_SPACE, GLFW_KEY_ENTER, GLFW_KEY_KP_ENTER
Tecla de PlegadoGLFW_KEY_LEFT (Sólo cuando está desplegado)
Tecla de DespliegueGLFW_KEY_RIGHT (Sólo cuando está plegado)
Sonido de InteracciónSoundEvents.UI_BUTTON_CLICK (1.0F)

📖 Visión General

Collapsible Game Rules incluye soporte completo para navegación con teclado y narración en pantalla, permitiendo configurar todas las opciones mediante teclado, mando o lectores de pantalla sin depender del ratón.


⌨️ Asignación de Teclas

Cuando un encabezado de categoría tiene el foco en RuleList, el método keyPressed(KeyEvent event) responde a los siguientes eventos:

TeclaConstante GLFWAcciónCondiciónSonido
EspacioGLFW_KEY_SPACEAlternar DespliegueSiempreUI_BUTTON_CLICK
EnterGLFW_KEY_ENTERAlternar DespliegueSiempreUI_BUTTON_CLICK
Enter NuméricoGLFW_KEY_KP_ENTERAlternar DespliegueSiempreUI_BUTTON_CLICK
Flecha Izquierda (←)GLFW_KEY_LEFTPlegar CategoríaSólo si expanded == trueUI_BUTTON_CLICK
Flecha Derecha (→)GLFW_KEY_RIGHTDesplegar CategoríaSólo si expanded == falseUI_BUTTON_CLICK

⚙️ Implementación Técnica

1. Procesamiento de Teclas Direccionales

Sigue los convenios estándar de navegación en árbol de los sistemas operativos:

java
@Override
public boolean keyPressed(KeyEvent event) {
    int keyCode = event.key();
    if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER || keyCode == GLFW.GLFW_KEY_SPACE) {
        this.toggleAction.run();
        Minecraft.getInstance().getSoundManager()
                .play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
        return true;
    } else if (keyCode == GLFW.GLFW_KEY_LEFT && this.expanded) {
        this.toggleAction.run();
        Minecraft.getInstance().getSoundManager()
                .play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
        return true;
    } else if (keyCode == GLFW.GLFW_KEY_RIGHT && !this.expanded) {
        this.toggleAction.run();
        Minecraft.getInstance().getSoundManager()
                .play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
        return true;
    }
    return super.keyPressed(event);
}

2. Narración para Accesibilidad (updateNarration)

java
@Override
public NarrationPriority narrationPriority() {
    return NarrationPriority.HOVERED;
}

@Override
public void updateNarration(NarrationElementOutput output) {
    output.add(NarratedElementType.TITLE, this.label);
}

🔗 Documentación Relacionada

Official documentation & web portal for Dasik Igaijinn mods.