Skip to content

Commit

Permalink
Revert "Fixes to Input and CheckBox when updating styles (#101)"
Browse files Browse the repository at this point in the history
This reverts commit 9dcf683.
  • Loading branch information
CyberDex committed Oct 20, 2023
1 parent 9dcf683 commit e4737cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 39 deletions.
7 changes: 0 additions & 7 deletions src/CheckBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ export class CheckBox extends Switcher
/** Setter, which sets a checkbox style settings. */
set style(style: CheckBoxStyle)
{
// Preserve checked state for the end of the method
const wasChecked = this.checked;

this._style = style;

const { unchecked, checked } = style;
Expand All @@ -113,10 +110,6 @@ export class CheckBox extends Switcher
this.label.x = uncheckedView.width + 10 + (style.textOffset?.x ?? 0);
this.label.y = ((uncheckedView.height - this.label.height) / 2) + (style.textOffset?.y ?? 0);
}

// Reset checked state
delete this._active;
this.checked = wasChecked;
}

/** Getter, which returns a checkbox style settings. */
Expand Down
40 changes: 8 additions & 32 deletions src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class Input extends Container

const defaultTextStyle = {
fill: 0x000000,
align: 'center',
align: 'center'
} as TextStyle;

this.options.textStyle = options.textStyle ?? defaultTextStyle;
Expand All @@ -147,10 +147,7 @@ export class Input extends Container
this._cursor.height = this.inputField.height * 0.8;
this._cursor.alpha = 0;

this.placeholder = new Text(
options.placeholder,
textStyle ?? defaultTextStyle
);
this.placeholder = new Text(options.placeholder, textStyle ?? defaultTextStyle);
this.placeholder.visible = !!options.placeholder;

this.addChild(this.inputField, this.placeholder, this._cursor);
Expand All @@ -172,10 +169,7 @@ export class Input extends Container
this._bg.cursor = 'text';
this._bg.interactive = true;

if (!this._bg.parent)
{
this.addChildAt(this._bg, 0);
}
this.addChildAt(this._bg, 0);

if (!this.inputField)
{
Expand Down Expand Up @@ -218,10 +212,7 @@ export class Input extends Container
return;
}

if (
this.options.maxLength
&& this.value.length >= this.options.maxLength
)
if (this.options.maxLength && this.value.length >= this.options.maxLength)
{
return;
}
Expand Down Expand Up @@ -269,11 +260,6 @@ export class Input extends Container
this.input.removeEventListener('blur', this.stopEditingBinding);
this.input.removeEventListener('keyup', this.onKeyUpBinding);

this._keyboard.oninput = (event) =>
{
let value = this._keyboard.value;
}

this.input?.blur();
this.input?.remove();
this.input = null;
Expand Down Expand Up @@ -370,16 +356,11 @@ export class Input extends Container
const align = this.getAlign();

this.inputField.anchor.set(align, 0.5);
this.inputField.x
= (this._bg.width * align)
+ (align === 1 ? -this.paddingRight : this.paddingLeft);
this.inputField.y
= (this._bg.height / 2) + this.paddingTop - this.paddingBottom;
this.inputField.x = (this._bg.width * align) + (align === 1 ? -this.paddingRight : this.paddingLeft);
this.inputField.y = (this._bg.height / 2) + this.paddingTop - this.paddingBottom;

this.placeholder.anchor.set(align, 0.5);
this.placeholder.x
= (this._bg.width * align)
+ (align === 1 ? -this.paddingRight : this.paddingLeft);
this.placeholder.x = (this._bg.width * align) + (align === 1 ? -this.paddingRight : this.paddingLeft);
this.placeholder.y = this._bg.height / 2;

this._cursor.x = this.getCursorPosX();
Expand Down Expand Up @@ -490,12 +471,7 @@ export class Input extends Container
// Return array of paddings [top, right, bottom, left]
get padding(): [number, number, number, number]
{
return [
this.paddingTop,
this.paddingRight,
this.paddingBottom,
this.paddingLeft,
];
return [this.paddingTop, this.paddingRight, this.paddingBottom, this.paddingLeft];
}

override destroy(options?: IDestroyOptions | boolean)
Expand Down

0 comments on commit e4737cb

Please sign in to comment.