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 Paste button 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 Paste button 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 Paste button.<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 Paste button. 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 Paste button will be in the default style. 53 54**Atomic service API**: This API can be used in atomic services since API version 11. 55 56**System capability**: SystemCapability.ArkUI.ArkUI.Full 57 58| Name| Type| Mandatory| Description| 59| -------- | -------- | -------- | -------- | 60| icon | [PasteIconStyle](#pasteiconstyle) | No| Icon style of the Paste button.<br>If this parameter is not specified, there is no icon.| 61| text | [PasteDescription](#pastedescription) | No| Text on the Paste button.<br>If this parameter is not specified, there is no text description.| 62| buttonType | [ButtonType](ts-basic-components-button.md#buttontype) | No| Background style of the Paste button.<br>If this parameter is not specified, the system uses a capsule-type button.| 63 64## Attributes 65 66This component can only inherit the [universal attributes of security components](ts-securitycomponent-attributes.md). 67 68## PasteIconStyle 69 70**Atomic service API**: This API can be used in atomic services since API version 11. 71 72**System capability**: SystemCapability.ArkUI.ArkUI.Full 73 74| Name| Value| Description| 75| -------- | -------- | -------- | 76| LINES | 0 | Line style icon.| 77 78## PasteDescription 79 80**Atomic service API**: This API can be used in atomic services since API version 11. 81 82**System capability**: SystemCapability.ArkUI.ArkUI.Full 83 84| Name| Value| Description| 85| -------- | -------- | -------- | 86| PASTE | 0 | The text on the Paste button is **Paste**.| 87 88## PasteButtonOnClickResult 89 90**Atomic service API**: This API can be used in atomic services since API version 11. 91 92**System capability**: SystemCapability.ArkUI.ArkUI.Full 93 94| Name| Value| Description| 95| -------- | -------- | -------- | 96| SUCCESS | 0 | The Paste button is touched successfully.| 97| TEMPORARY_AUTHORIZATION_FAILED | 1 | Temporary authorization fails after the Paste button is touched.| 98 99## Events 100 101Only the following events are supported. 102 103### onClick 104 105onClick(event: (event: ClickEvent, result: PasteButtonOnClickResult) => void) 106 107Called when a click event occurs. 108 109**Atomic service API**: This API can be used in atomic services since API version 11. 110 111**System capability**: SystemCapability.ArkUI.ArkUI.Full 112 113**Parameters** 114 115| Name| Type | Mandatory| Description | 116|------------|------|-------|---------| 117| event | [ClickEvent](ts-universal-events-click.md#clickevent) |Yes|See **ClickEvent**.| 118| result | [PasteButtonOnClickResult](#pastebuttononclickresult)| Yes| Authorization result. After the authorization, the pasteboard content can be read.| 119 120## Example 121 122```ts 123// xxx.ets 124@Entry 125@Component 126struct Index { 127 build() { 128 Row() { 129 Column({space:10}) { 130 // Create a default button with an icon, text, and background. 131 PasteButton().onClick((event: ClickEvent, result: PasteButtonOnClickResult)=>{ 132 console.info("result " + result) 133 }) 134 // 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. 135 PasteButton({icon:PasteIconStyle.LINES}) 136 // 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. 137 PasteButton({icon:PasteIconStyle.LINES, buttonType:ButtonType.Capsule}) 138 .backgroundColor(0x10007dff) 139 // 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. 140 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 141 // 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. 142 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 143 .fontSize(16) 144 .width(30) 145 // 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. 146 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 147 .fontSize(16) 148 .size({width: 30, height: 30}) 149 // 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. 150 PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule}) 151 .fontSize(16) 152 .constraintSize({minWidth: 0, maxWidth: 30, minHeight: 0, maxHeight: 30}) 153 }.width('100%') 154 }.height('100%') 155 } 156} 157``` 158 159 160