# lv_gridnav.h (/api/indev/lv_gridnav_h)



<ApiSummary functions="3" enums="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (1)&#x22;,&#x22;Other (2)&#x22;]">
  <ApiTab value="Setters (1)">
    <ApiMember kind="function" name="lv_gridnav_set_focused" file="indev/lv_gridnav.h" line="84" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/indev/lv_gridnav.h#L84">
      lv_gridnav_set_focused [#lv_gridnav_set_focused]

      Manually focus an object on gridnav container

      ```c title=" " lineNumbers=1
      void lv_gridnav_set_focused(lv_obj_t *cont, lv_obj_t *to_focus, lv_anim_enable_t anim_en)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name       | Type                                             | Description                    |
      | ---------- | ------------------------------------------------ | ------------------------------ |
      | `cont`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a gridnav container |
      | `to_focus` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object to focus  |
      | `anim_en`  | <ApiLink name="lv_anim_enable_t" />              | LV\_ANIM\_ON/OFF               |
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (2)">
    <ApiMember kind="function" name="lv_gridnav_add" file="indev/lv_gridnav.h" line="70" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/indev/lv_gridnav.h#L70">
      lv_gridnav_add [#lv_gridnav_add]

      Add grid navigation feature to an object. It expects the children to be arranged into a grid-like layout. Although it's not required to have pixel perfect alignment. This feature makes possible to use keys to navigate among the children and focus them. The keys other than arrows and press/release related events are forwarded to the focused child.

      ```c title=" " lineNumbers=1
      void lv_gridnav_add(lv_obj_t *obj, lv_gridnav_ctrl_t ctrl)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                             | Description                                                 |
      | ------ | ------------------------------------------------ | ----------------------------------------------------------- |
      | `obj`  | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object on which navigation should be applied. |
      | `ctrl` | <ApiLink name="lv_gridnav_ctrl_t" />             | control flags from `lv_gridnav_ctrl_t`.                     |
    </ApiMember>

    <ApiMember kind="function" name="lv_gridnav_remove" file="indev/lv_gridnav.h" line="76" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/indev/lv_gridnav.h#L76">
      lv_gridnav_remove [#lv_gridnav_remove]

      Remove the grid navigation support from an object

      ```c title=" " lineNumbers=1
      void lv_gridnav_remove(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |
    </ApiMember>
  </ApiTab>
</ApiTabs>

Enums [#enums]

<ApiMember kind="enum" name="lv_gridnav_ctrl_t" file="indev/lv_gridnav.h" line="27" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/indev/lv_gridnav.h#L27">
  lv_gridnav_ctrl_t [#lv_gridnav_ctrl_t]

  | Name                                   | Value | Description                                                                                                                                                                                                                                     |
  | -------------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `LV_GRIDNAV_CTRL_NONE`                 | `0x0` |                                                                                                                                                                                                                                                 |
  | `LV_GRIDNAV_CTRL_ROLLOVER`             | `0x1` | If there is no next/previous object in a direction, the focus goes to the object in the next/previous row (on left/right keys) or first/last row (on up/down keys)                                                                              |
  | `LV_GRIDNAV_CTRL_SCROLL_FIRST`         | `0x2` | If an arrow is pressed and the focused object can be scrolled in that direction then it will be scrolled instead of going to the next/previous object. If there is no more room for scrolling the next/previous object will be focused normally |
  | `LV_GRIDNAV_CTRL_HORIZONTAL_MOVE_ONLY` | `0x4` | Only use left/right keys for grid navigation. Up/down key events will be sent to the focused object.                                                                                                                                            |
  | `LV_GRIDNAV_CTRL_VERTICAL_MOVE_ONLY`   | `0x8` | Only use up/down keys for grid navigation. Left/right key events will be sent to the focused object.                                                                                                                                            |
</ApiMember>

<TypeUsedBy name="lv_gridnav_ctrl_t" count="1">
  * `lv_gridnav_add` — param `ctrl`
</TypeUsedBy>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_obj.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_array.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_display.h&#x22;, &#x22;lv_draw.h&#x22;, &#x22;lv_draw_arc.h&#x22;, &#x22;lv_draw_blur.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_draw_image.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_draw_line.h&#x22;, &#x22;lv_draw_rect.h&#x22;, &#x22;lv_draw_triangle.h&#x22;, &#x22;lv_event.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_fs.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_image_decoder.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_indev.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_matrix.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_obj_class.h&#x22;, &#x22;lv_obj_draw.h&#x22;, &#x22;lv_obj_event.h&#x22;, &#x22;lv_obj_pos.h&#x22;, &#x22;lv_obj_property.h&#x22;, &#x22;lv_obj_property_names.h&#x22;, &#x22;lv_obj_scroll.h&#x22;, &#x22;lv_obj_style.h&#x22;, &#x22;lv_obj_style_gen.h&#x22;, &#x22;lv_obj_tree.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_profiler.h&#x22;, &#x22;lv_profiler_builtin.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_style_properties.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
