import { emitter } from '@kit.BasicServicesKit';
@CustomDialog
struct CustomDialogExample {
@State sign: number = 100
controller: CustomDialogController = new CustomDialogController({
builder: CustomDialogExample(),
})
aa: () => void = () => {
}
cancel() {
console.log('23')
this.controller1.stopEditing();
}
@State text: string = ''
@State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 }
controller1: TextAreaController = new TextAreaController()
aboutToAppear() {
emitter.on({ eventId: 1, priority: emitter.EventPriority.LOW }, () => {
console.log('999')
this.sign = 100
})
}
build() {
Column() {
TextArea({
text: this.text,
placeholder: 'The text area can hold an unlimited amount of text. input your word...',
controller: this.controller1
})
.placeholderFont({ size: 16, weight: 400 })
.width(336)
.height(50)
.fontSize(16)
.fontColor('#182431')
.backgroundColor('#FFFFFF')
.onChange((value: string) => {
this.text = value
})
.onFocus(() => {
this.sign = 300
})
Button('dian').onClick(() => {
this.sign = 300
})
Button('dian').onClick(() => {
this.sign = 100
})
}.height(this.sign).backgroundColor('#ff23f60e')
}
}
@Entry
@Preview
@Component
struct Index {
@State message: string = 'Hello World';
dialogController: CustomDialogController = new CustomDialogController({
alignment: DialogAlignment.Bottom,
autoCancel: false,
cancel: () => {
console.log('888')
// emitter.emit({
// eventId: 1,
// priority: emitter.EventPriority.LOW
// }, { data: {} });
},
offset: { dx: 0, dy: 0 },
builder: CustomDialogExample({
aa: () => {
this.aa()
}
}),
})
aa() {
console.log('1212121')
}
aboutToAppear() {
this.dialogController.open();
}
build() {
Column() {
Column() {
}.width('100%').height('40').backgroundColor('#ff1df307')
Column() {
}.width('100%').height('calc(100% - 140vp)').backgroundColor('#ff224385')
Column() {
}.width('100%').height('100').backgroundColor('#ff1df307')
}.width("100%").height("100%").backgroundColor('red')
}
}
1212121212
于 2024-08-07 01:30:57 首次发布