gpui-focus-handle
Focus management and keyboard navigation in GPUI. Use when handling focus, focus handles, or keyboard navigation. Enables keyboard-driven interfaces with proper focus tracking and navigation between focusable elements.
Installation
Pick a client and clone the repository into its skills directory.
Installation
About this skill
Focus management and keyboard navigation in GPUI. Use when handling focus, focus handles, or keyboard navigation. Enables keyboard-driven interfaces with proper focus tracking and navigation between focusable elements.
How to use
Utwórz strukturę komponentu z polem FocusHandle — w metodzie new() pobierz uchwyt fokusa za pomocą cx.focus_handle() i przypisz go do pola struktury.
W metodzie render() oznacz element jako focusable, dodając .track_focus() z referencją do focus_handle, aby system śledził jego stan.
Dodaj obsługę akcji klawiszowych za pomocą .on_action() — na przykład obsłuż Enter, aby wyzwolić logikę biznesową komponentu.
Użyj metody focus_handle.focus(cx) aby programowo ustawić fokus na element, lub is_focused(cx) aby sprawdzić, czy element ma aktualnie fokus.
Obsługuj zdarzenia fokusa — w render() sprawdź is_focused() i dostosuj wygląd lub zachowanie elementu na podstawie stanu fokusa.
Implementuj rozmycie fokusa za pomocą cx.blur(), gdy użytkownik opuści element lub zatwierdzisz akcję.