* Set button state * 设置按钮状态
(value: string)
| 346 | * 设置按钮状态 |
| 347 | */ |
| 348 | protected setState(value: string): void { |
| 349 | if (this._buttonController) { |
| 350 | this._buttonController.selectedPage = value; |
| 351 | } |
| 352 | |
| 353 | if (this._downEffect === 1) { |
| 354 | const cnt = this.numChildren; |
| 355 | if ( |
| 356 | value === GButton.DOWN || |
| 357 | value === GButton.SELECTED_OVER || |
| 358 | value === GButton.SELECTED_DISABLED |
| 359 | ) { |
| 360 | const r = Math.round(this._downEffectValue * 255); |
| 361 | const color = '#' + ((r << 16) + (r << 8) + r).toString(16).padStart(6, '0'); |
| 362 | for (let i = 0; i < cnt; i++) { |
| 363 | const obj = this.getChildAt(i); |
| 364 | if (!(obj instanceof GTextField)) { |
| 365 | obj.setProp(EObjectPropID.Color, color); |
| 366 | } |
| 367 | } |
| 368 | } else { |
| 369 | for (let i = 0; i < cnt; i++) { |
| 370 | const obj = this.getChildAt(i); |
| 371 | if (!(obj instanceof GTextField)) { |
| 372 | obj.setProp(EObjectPropID.Color, '#FFFFFF'); |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | } else if (this._downEffect === 2) { |
| 377 | if ( |
| 378 | value === GButton.DOWN || |
| 379 | value === GButton.SELECTED_OVER || |
| 380 | value === GButton.SELECTED_DISABLED |
| 381 | ) { |
| 382 | if (!this._downScaled) { |
| 383 | this.setScale( |
| 384 | this.scaleX * this._downEffectValue, |
| 385 | this.scaleY * this._downEffectValue |
| 386 | ); |
| 387 | this._downScaled = true; |
| 388 | } |
| 389 | } else { |
| 390 | if (this._downScaled) { |
| 391 | this.setScale( |
| 392 | this.scaleX / this._downEffectValue, |
| 393 | this.scaleY / this._downEffectValue |
| 394 | ); |
| 395 | this._downScaled = false; |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | public handleControllerChanged(c: Controller): void { |
| 402 | super.handleControllerChanged(c); |
no test coverage detected