> ## 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.

# XGameUiShowTextEntryAsync

> XGameUiShowTextEntryAsync

# XGameUiShowTextEntryAsync

顯示文字輸入 UI，讓使用者輸入資訊。

## 語法

```cpp theme={null}
HRESULT XGameUiShowTextEntryAsync(  
         XAsyncBlock* async,  
         const char* titleText,  
         const char* descriptionText,  
         const char* defaultText,  
         XGameUiTextEntryInputScope inputScope,  
         uint32_t maxTextLength  
)  
```

### 參數

*async*   \_In\_<br />類型：[XAsyncBlock\*](/zh-TW/reference/system/xasync/structs/xasyncblock)

指向傳遞給 [XAsyncRun](/zh-TW/reference/system/xasync/functions/xasyncrun) 之 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 的指標。

*titleText*   \_In\_opt\_z\_<br />類型：char\*

文字輸入 UI 的文字標題。

*descriptionText*   \_In\_opt\_z\_<br />類型：char\*

文字輸入 UI 的文字描述。

*defaultText*   \_In\_opt\_z\_<br />類型：char\*

一開始填入文字輸入 UI 的預設文字。

*inputScope*   \_In\_<br />類型：[XGameUiTextEntryInputScope](/zh-TW/reference/system/xgameui/enums/xgameuitextentryinputscope)

指定文字輸入的輸入範圍，表示允許的資訊類型。此範圍可提示遊戲可能需要的文字。遊戲仍需要驗證從鍵盤取回的文字。

*maxTextLength*   \_In\_<br />類型：uint32\_t

使用者可在文字輸入 UI 中輸入的最大字元數。在主機上，最大字元數為 1024。在 PC 上則沒有限制。如果傳入值 0，將視為最大字元長度 1024。此外，如果 *inputScope* 是 XGameUiTextEntryInputScope::Password，最大長度一律為 1024，且會忽略 *maxTextLength* 值。

### 傳回值

類型：HRESULT

非同步呼叫的 HRESULT 成功或錯誤碼。

若要取得結果，請在 *AsyncBlock* 回呼內或 *AsyncBlock* 完成之後，呼叫 [XGameUiShowTextEntryResultSize](/zh-TW/reference/system/xgameui/functions/xgameuishowtextentryresultsize) 和 [XGameUiShowTextEntryResult](/zh-TW/reference/system/xgameui/functions/xgameuishowtextentryresult)。

## 備註

在主機上，這會同時提供文字輸入欄位和螢幕虛擬鍵盤 (OSK)。在 Windows 上，這會提供一個含有文字輸入欄位的新視窗。只有在使用者設定為使用螢幕小鍵盤 (例如處於平板電腦模式) 而非實體鍵盤時，Windows 上才會出現虛擬鍵盤。

呼叫 UI 會讓您的遊戲進入 *受限模式*。在受限模式下，當您的遊戲位於所呼叫 UI 的背景時，會獲得較少的系統資源。若要深入了解受限模式及遊戲的其他作業模式，請參閱 [XBOX 遊戲生命週期 (NDA 主題)](/zh-TW/build/console-features/console-workflows/xbox-game-life-cycle)。

## 需求

**標頭：** XGameUI.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、Steam Deck、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[XGameUI](/zh-TW/reference/system/xgameui/xgameui_members)<br />[虛擬鍵盤支援](/zh-TW/build/core-features/common/input/overviews/virtualkeyboardsupport) [XGameUIShowTextEntryResult](/zh-TW/reference/system/xgameui/functions/xgameuishowtextentryresult)<br />[XGameUIShowTextEntryResultSize](/zh-TW/reference/system/xgameui/functions/xgameuishowtextentryresultsize)<br />[XBOX 遊戲生命週期 (NDA 主題)](/zh-TW/build/console-features/console-workflows/xbox-game-life-cycle)


## Related topics

- [XGameUiShowTextEntryAsync](/reference/system/xgameui/functions/xgameuishowtextentryasync.md)
- [XGameUiShowTextEntryResult](/reference/system/xgameui/functions/xgameuishowtextentryresult.md)
- [XGameUiShowTextEntryResultSize](/reference/system/xgameui/functions/xgameuishowtextentryresultsize.md)
- [XGameUiShowTextEntryUiCallback](/reference/system/xgameui/functions/xgameuishowtextentryuicallback.md)
