1# PasteButton 2 3The **PasteButton** security component represents a paste button that allows you to obtain temporary pasteboard permissions from users with a simple button touch. 4 5> **NOTE** 6> 7> This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version. 8 9## Child Components 10 11Not supported 12 13## APIs 14 15### PasteButton 16 17PasteButton() 18 19Creates a **PasteButton** component with an icon, text, and background. 20 21You may want to learn the [restrictions on security component styles](../../../security/AccessToken/security-component-overview.md#constraints) to avoid authorization failures caused by incompliant styles. 22 23**Atomic service API**: This API can be used in atomic services since API version 11. 24 25**System capability**: SystemCapability.ArkUI.ArkUI.Full 26 27### PasteButton 28 29PasteButton(options: PasteButtonOptions) 30 31Creates a **PasteButton** component that contains the specified elements. 32 33You may want to learn the [restrictions on security component styles](../../../security/AccessToken/security-component-overview.md#constraints) to avoid authorization failures caused by incompliant styles. 34 35**Atomic service API**: This API can be used in atomic services since API version 11. 36 37**System capability**: SystemCapability.ArkUI.ArkUI.Full 38 39**Parameters** 40 41| Name| Type| Mandatory| Description| 42| -------- | -------- | -------- | -------- | 43| options | [PasteButtonOptions](#pastebuttonoptions) | Yes| Options for creating the **PasteButton** component.<br>Default value:<br>{<br>icon: PasteIconStyle.LINES,<br>text: PasteDescription.PASTE,<br>buttonType: ButtonType.Capsule <br>} | 44 45## PasteButtonOptions 46 47Describes the icon, text, and other specific elements for the **PasteButton** component. 48 49> **NOTE** 50> 51> - At least one of **icon** or **text** must be provided.<br> 52> - If neither **icon** nor **text** is provided, the **options** parameter in [PasteButton](#pastebutton-1) will not take effect, and the created **PasteButton** component will use the default style: 53> 54> The default value of **PasteIconStyle** is **LINES**. 55> 56> The default style of **PasteDescription** is **PASTE**. 57> 58> The default value of **ButtonType** is **Capsule**. 59> - The **icon**, **text**, and **buttonType** parameters do not support dynamic modification. 60 61**Atomic service API**: This API can be used in atomic services since API version 11. 62 63**System capability**: SystemCapability.ArkUI.ArkUI.Full 64 65| Name| Type| Mandatory| Description| 66| -------- | -------- | -------- | -------- | 67| icon | [PasteIconStyle](#pasteiconstyle) | No| Icon style of the **PasteButton** component.<br>If this parameter is not specified, there is no icon.| 68| text | [PasteDescription](#pastedescription) | No| Text on the **PasteButton** component.<br>If this parameter is not specified, there is no text description.| 69| buttonType | [ButtonType](ts-basic-components-button.md#buttontype) | No| Background style of the **PasteButton** componen.<br>If this parameter is not specified, the system uses a capsule-type button.| 70 71## Attributes 72 73This component can only inherit the [universal attributes of security components](ts-securitycomponent-attributes.md). 74 75## PasteIconStyle 76 77**Atomic service API**: This API can be used in atomic services since API version 11. 78 79**System capability**: SystemCapability.ArkUI.ArkUI.Full 80 81| Name| Value| Description| 82| -------- | -------- | -------- | 83| LINES | 0 | Line style icon.| 84 85## PasteDescription 86 87**Atomic service API**: This API can be used in atomic services since API version 11. 88 89**System capability**: SystemCapability.ArkUI.ArkUI.Full 90 91| Name| Value| Description| 92| -------- | -------- | -------- | 93| PASTE | 0 | The text on the **PasteButton** component is **Paste**.| 94 95## PasteButtonOnClickResult 96 97**Atomic service API**: This API can be used in atomic services since API version 11. 98 99**System capability**: SystemCapability.ArkUI.ArkUI.Full 100 101| Name| Value| Description| 102| -------- | -------- | -------- | 103| SUCCESS | 0 | The **PasteButton** component is touched successfully.| 104| TEMPORARY_AUTHORIZATION_FAILED | 1 | Temporary authorization fails after the **PasteButton** component is touched.| 105 106## Events 107 108Only the following events are supported. 109 110### onClick 111 112onClick(event: (event: ClickEvent, result: PasteButtonOnClickResult) => void) 113 114Called when a click event occurs. 115 116**Atomic service API**: This API can be used in atomic services since API version 11. 117 118**System capability**: SystemCapability.ArkUI.ArkUI.Full 119 120**Parameters** 121 122| Name| Type | Mandatory| Description | 123|------------|------|-------|---------| 124| event | [ClickEvent](ts-universal-events-click.md#clickevent) |Yes|See **ClickEvent**.| 125| result | [PasteButtonOnClickResult](#pastebuttononclickresult)| Yes| Authorization result. After the authorization, the pasteboard content can be read.| 126 127## Example 128 129```ts 130// xxx.ets 131@Entry 132@Component 133struct Index { 134 build() { 135 Row() { 136 Column({space:10}) { 137 // Create a default button with an icon, text, and background. 138 PasteButton().onClick((event: ClickEvent, result: PasteButtonOnClickResult)=>{ 139 console.info("result " + result) 140 }) 141 // Whether an element is contained depends on whether the parameter corresponding to the element is specified. If buttonType is not passed in, the button uses the ButtonType.Capsule settings. 142 PasteButton({icon:PasteIconStyle.LINES}) 143 // Create a button with only an icon and background. If the alpha value of the most significant eight bits of the background color is less than 0x1A, the system forcibly adjusts the alpha value to 0xFF. 144 PasteButton({icon:PasteIconStyle.LINES, buttonType:ButtonType.Capsule}) 145 .backgroundColor(0x10007dff) 146 // Create a button with an icon, text, and background. If the alpha value of the most significant eight bits of the background color is less than 0x1A, the system forcibly adjusts the alpha value to 0xFF. 147 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 148 // Create a button with an icon, text, and background. If the set width is less than the minimum allowed, the button's text will wrap to guarantee full text display. 149 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 150 .fontSize(16) 151 .width(30) 152 // Create a button with an icon, text, and background. If the set width is less than the minimum allowed, the button's text will wrap to guarantee full text display. 153 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 154 .fontSize(16) 155 .size({width: 30, height: 30}) 156 // Create a button with an icon, text, and background. If the set width is less than the minimum allowed, the button's text will wrap to guarantee full text display. 157 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 158 .fontSize(16) 159 .constraintSize({minWidth: 0, maxWidth: 30, minHeight: 0, maxHeight: 30}) 160 }.width('100%') 161 }.height('100%') 162 } 163} 164``` 165 166 167