MCPcopy Create free account
hub / github.com/esengine/esengine / setState

Method setState

packages/fairygui/src/widgets/GButton.ts:348–399  ·  view source on GitHub ↗

* Set button state * 设置按钮状态

(value: string)

Source from the content-addressed store, hash-verified

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);

Callers 8

selectedMethod · 0.95
fireClickMethod · 0.95
handleGrayedChangedMethod · 0.95
constructExtensionMethod · 0.95
handleRollOverMethod · 0.95
handleRollOutMethod · 0.95
handleTouchBeginMethod · 0.95
handleTouchEndMethod · 0.95

Calls 4

getChildAtMethod · 0.80
toStringMethod · 0.45
setPropMethod · 0.45
setScaleMethod · 0.45

Tested by

no test coverage detected