QML KeyNavigation ElementThe KeyNavigation attached property supports key navigation by arrow keys. More... This element was introduced in Qt 4.7. PropertiesDetailed DescriptionKey-based user interfaces commonly allow the use of arrow keys to navigate between focusable items. The KeyNavigation attached property enables this behavior by providing a convenient way to specify the item that should gain focus when an arrow or tab key is pressed. The following example provides key navigation for a 2x2 grid of items: import QtQuick 1.0 Grid { width: 100; height: 100 columns: 2 Rectangle { id: topLeft width: 50; height: 50 color: focus ? "red" : "lightgray" focus: true KeyNavigation.right: topRight KeyNavigation.down: bottomLeft } Rectangle { id: topRight width: 50; height: 50 color: focus ? "red" : "lightgray" KeyNavigation.left: topLeft KeyNavigation.down: bottomRight } Rectangle { id: bottomLeft width: 50; height: 50 color: focus ? "red" : "lightgray" KeyNavigation.right: bottomRight KeyNavigation.up: topLeft } Rectangle { id: bottomRight width: 50; height: 50 color: focus ? "red" : "lightgray" KeyNavigation.left: bottomLeft KeyNavigation.up: topRight } } The top-left item initially receives focus by setting focus to true. When an arrow key is pressed, the focus will move to the appropriate item, as defined by the value that has been set for the KeyNavigation left, right, up or down properties. Note that if a KeyNavigation attached property receives the key press and release events for a requested arrow or tab key, the event is accepted and does not propagate any further. By default, KeyNavigation receives key events after the item to which it is attached. If the item accepts the key event, the KeyNavigation attached property will not receive an event for that key. Setting the priority property to KeyNavigation.BeforeItem allows the event to be used for key navigation before the item, rather than after. If item to which the focus is switching is not enabled or visible, an attempt will be made to skip this item and focus on the next. This is possible if there are a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled or visible, they will also be skipped. See also Keys attached property. Property DocumentationThese properties hold the item to assign focus to when the left, right, up or down cursor keys, or the tab key are pressed. This property determines whether the keys are processed before or after the attached item's own key handling.
These properties hold the item to assign focus to when the Tab key or Shift+Tab key combination (Backtab) are pressed. |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.8 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com