> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XGameUiTextEntryGetState

> XGameUiTextEntryGetState

# XGameUiTextEntryGetState

Gets the current state of the open virtual keyboard.

## Syntax

```cpp theme={null}
HRESULT XGameUiTextEntryGetState(  
         XGameUiTextEntryHandle handle,
         XGameUiTextEntryChangeTypeFlags* changeType,
         uint32_t* cursorIndex,
         uint32_t* imeClauseStartIndex,
         uint32_t* imeClauseEndIndex,
         uint32_t bufferSize,
         char* buffer
)  
```

### Parameters

*handle*   \_In\_\
Type: XGameUiTextEntryHandle

Handle to the opened virtual keyboard.

*changeType*   \_Out\_\
Type: [XGameUiTextEntryChangeTypeFlags\*](/reference/system/xgameui/enums/xgameuitextentrychangetypeflags)

Describes if the text has changed or the virtual keyboard has been dismissed since the last time
that the game called *XGameUiTextEntryGetState*. If the change type indicates that the virtual
keyboard has been dismissed, the game must call [XGameUiTextEntryClose](/reference/system/xgameui/functions/xgameuitextentryclose)
once it is done handling the text changes.

*cursorIndex*   \_Out\_opt\_\
Type: uint32\_t\*

Byte index of the cursor relative to the starting character.

*imeClauseStartIndex*   \_Out\_opt\_\
Type: uint32\_t\*

Starting byte index of the IME clause that might get replaced by an IME candidate. This will
be prior to the cursor index. If IME isn't in use, this value will be zero.

*imeClauseEndIndex*   \_Out\_opt\_\
Type: uint32\_t\*

Ending byte index of the IME clause that might get replaced by an IME candidate. This will
be after the cursor index. If IME isn't in use, this value will be zero.

*bufferSize*   \_In\_\
Type: uint32\_t

Size in bytes of the game-provided buffer that will get the text from the virtual keyboard.

*buffer*   \_Out\_\
Type: char\*

Complete text entered into the virtual keyboard as a null-terminated character string. Newline will
get represented as '\n'.

### Return value

Type: HRESULT

HRESULT success or error code. For a list of error codes, see [Error Codes](/reference/errorcodes).

| Return Code                      | Description                                                                                    |
| -------------------------------- | ---------------------------------------------------------------------------------------------- |
| S\_OK                            | The operation succeeded.                                                                       |
| E\_GAMEUI\_TEXTENTRY\_NOT\_SHOWN | The XGameUiTextEntryHandle is not valid, likely because you need to call XGameUiTextEntryOpen. |

## Remarks

This function needs to be called at least once per frame to get the latest virtual keyboard changes.
If the keyboard is later dismissed, the function will return successfully; however, the change type
will include KeyboardDismissed.

## Requirements

**Header:** XGameUI.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[XGameUI](/reference/system/xgameui/xgameui_members)\
[XGameUiTextEntryOpen](/reference/system/xgameui/functions/xgameuitextentryopen)
[XGameUiTextEntryClose](/reference/system/xgameui/functions/xgameuitextentryclose)


## Related topics

- [XGameUiTextEntryChangeTypeFlags](/reference/system/xgameui/enums/xgameuitextentrychangetypeflags.md)
- [XGameUI](/reference/system/xgameui/xgameui_members.md)
- [XGameUiTextEntryGetExtents](/reference/system/xgameui/functions/xgameuitextentrygetextents.md)
- [XGameUiTextEntryVisibilityFlags](/reference/system/xgameui/enums/xgameuitextentryvisibilityflags.md)
- [XGameUiTextEntryOpen](/reference/system/xgameui/functions/xgameuitextentryopen.md)
