1# inputmethod_attach_options_capi.h 2<!--Kit: IME Kit--> 3<!--Subsystem: MiscServices--> 4<!--Owner: @illybyy--> 5<!--Designer: @andeszhang--> 6<!--Tester: @murphy1984--> 7<!--Adviser: @zhang_yixin13--> 8 9## Overview 10 11Provides methods for creating, destroying, reading, and writing the option object bound to the input method. 12 13**File to include**: <inputmethod/inputmethod_attach_options_capi.h> 14 15**Library**: libohinputmethod.so 16 17**System capability**: SystemCapability.MiscServices.InputMethodFramework 18 19**Since**: 12 20 21**Related module**: [InputMethod](capi-inputmethod.md) 22 23## Summary 24 25### Structs 26 27| Name| typedef Keyword| Description| 28| -- | -- | -- | 29| [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) | InputMethod_AttachOptions | Options for binding the input method. | 30 31### Function 32 33| Name| Description | 34| -- |------------------------------------------------| 35| [InputMethod_AttachOptions *OH_AttachOptions_Create(bool showKeyboard)](#oh_attachoptions_create) | Creates an [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. | 36| [InputMethod_AttachOptions *OH_AttachOptions_CreateWithRequestKeyboardReason(bool showKeyboard, InputMethod_RequestKeyboardReason requestKeyboardReason)](#oh_attachoptions_createwithrequestkeyboardreason) | Creates an [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. | 37| [void OH_AttachOptions_Destroy(InputMethod_AttachOptions *options)](#oh_attachoptions_destroy) | Destroys an [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. | 38| [InputMethod_ErrorCode OH_AttachOptions_IsShowKeyboard(InputMethod_AttachOptions *options, bool *showKeyboard)](#oh_attachoptions_isshowkeyboard) | Obtains the value that indicates whether to display the keyboard from [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md).| 39| [InputMethod_ErrorCode OH_AttachOptions_GetRequestKeyboardReason(InputMethod_AttachOptions *options, int *requestKeyboardReason)](#oh_attachoptions_getrequestkeyboardreason) | Obtains the value that indicates whether to display the keyboard from [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md).| 40 41## Function Description 42 43### OH_AttachOptions_Create() 44 45``` 46InputMethod_AttachOptions *OH_AttachOptions_Create(bool showKeyboard) 47``` 48 49**Description** 50 51Creates an [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. 52 53**Since**: 12 54 55 56**Parameters** 57 58| Name| Description| 59| -- | -- | 60| bool showKeyboard | Whether to display the keyboard.| 61 62**Returns** 63 64| Type| Description| 65| -- | -- | 66| [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) * | If the operation is successful, a pointer to the created [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance is returned.<br> If the operation failed, **NULL** is returned, which may be caused by insufficient application address space.| 67 68### OH_AttachOptions_CreateWithRequestKeyboardReason() 69 70``` 71InputMethod_AttachOptions *OH_AttachOptions_CreateWithRequestKeyboardReason(bool showKeyboard, InputMethod_RequestKeyboardReason requestKeyboardReason) 72``` 73 74**Description** 75 76Creates an [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. 77 78**Since**: 15 79 80 81**Parameters** 82 83| Name| Description| 84| -- | -- | 85| bool showKeyboard | Whether to display the keyboard.| 86| [InputMethod_RequestKeyboardReason](capi-inputmethod-types-capi-h.md#inputmethod_requestkeyboardreason) requestKeyboardReason | Reason for requesting the keyboard.| 87 88**Returns** 89 90| Type| Description| 91| -- | -- | 92| [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) * | If the operation is successful, a pointer to the created [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance is returned.<br> If the operation failed, **NULL** is returned, which may be caused by insufficient application address space.| 93 94### OH_AttachOptions_Destroy() 95 96``` 97void OH_AttachOptions_Destroy(InputMethod_AttachOptions *options) 98``` 99 100**Description** 101 102Destroys an [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. 103 104**Since**: 12 105 106 107**Parameters** 108 109| Name| Description| 110| -- | -- | 111| [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) *options | [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance to be destroyed.| 112 113### OH_AttachOptions_IsShowKeyboard() 114 115``` 116InputMethod_ErrorCode OH_AttachOptions_IsShowKeyboard(InputMethod_AttachOptions *options, bool *showKeyboard) 117``` 118 119**Description** 120 121Obtains the value that indicates whether to display the keyboard from [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md). 122 123**Since**: 12 124 125 126**Parameters** 127 128| Name| Description| 129| -- | -- | 130| [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) *options | Pointer to the [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance whose value is to be read.| 131| bool *showKeyboard | Pointer to whether to display the keyboard during binding. **true**: The keyboard is displayed after the binding is complete. **false**: The keyboard is hidden after the binding is complete.| 132 133**Returns** 134 135| Type| Description| 136| -- | -- | 137| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | An error code.<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - Success.<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - An unexpected null pointer.<br> For details about the error codes, see [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode).| 138 139### OH_AttachOptions_GetRequestKeyboardReason() 140 141``` 142InputMethod_ErrorCode OH_AttachOptions_GetRequestKeyboardReason(InputMethod_AttachOptions *options, int *requestKeyboardReason) 143``` 144 145**Description** 146 147Obtains the value that indicates whether to display the keyboard from [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md). 148 149**Since**: 15 150 151 152**Parameters** 153 154| Name| Description| 155| -- | -- | 156| [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) *options | Pointer to the [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance whose value is to be read.| 157| int *requestKeyboardReason | Pointer to the [InputMethod_AttachOptions](capi-inputmethod-inputmethod-attachoptions.md) instance. It indicates the reason for requesting the keyboard.| 158 159**Returns** 160 161| Type| Description| 162| -- | -- | 163| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | An error code.<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - Success.<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - An unexpected null pointer.<br> For details about the error codes, see [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode).| 164