1# @CustomDialog 2 3 4The @CustomDialog decorator is used to decorate custom pop-up dialog boxes. 5 6 7 8``` 9// custom-dialog-demo.ets 10@CustomDialog 11struct DialogExample { 12 controller: CustomDialogController; 13 action: () => void; 14 15 build() { 16 Row() { 17 Button ("Close CustomDialog") 18 .onClick(() => { 19 this.controller.close(); 20 this.action(); 21 }) 22 }.padding(20) 23 } 24} 25 26@Entry 27@Component 28struct CustomDialogUser { 29 dialogController : CustomDialogController = new CustomDialogController({ 30 builder: DialogExample({action: this.onAccept}), 31 cancel: this.existApp, 32 autoCancel: true 33 }); 34 35 onAccept() { 36 console.log("onAccept"); 37 } 38 existApp() { 39 console.log("Cancel dialog!"); 40 } 41 42 build() { 43 Column() { 44 Button("Click to open Dialog") 45 .onClick(() => { 46 this.dialogController.open() 47 }) 48 } 49 } 50} 51``` 52