Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Oct 20, 2023
1 parent be8d2dd commit 723efc2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type InputOptions = {
maxLength?: number;
align?: 'left' | 'center' | 'right';
padding?: Padding;
cleanOnFocus?: boolean;
};

/**
Expand Down Expand Up @@ -167,7 +168,7 @@ export class Input extends Container
this._bg.cursor = 'text';
this._bg.interactive = true;

this.addChild(this._bg);
this.addChildAt(this._bg, 0);

if (!this.inputField)
{
Expand Down Expand Up @@ -195,7 +196,7 @@ export class Input extends Container

this._cursor.mask = this.inputMask;

this.addChild(this.inputMask);
this.addChildAt(this.inputMask, 0);
}

get bg(): Container | string
Expand Down Expand Up @@ -233,6 +234,11 @@ export class Input extends Container

protected _startEditing(): void
{
if (this.options.cleanOnFocus)
{
this.value = '';
}

this.tick = 0;
this.editing = true;
this.placeholder.visible = false;
Expand Down
13 changes: 5 additions & 8 deletions src/stories/input/InputGraphics.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const args = {
paddingRight: 0,
paddingBottom: 0,
paddingLeft: 0,
cleanOnFocus: true,
onChange: action('Change')
};

Expand All @@ -45,7 +46,8 @@ export const UseGraphics = ({
paddingRight,
paddingBottom,
paddingLeft,
onChange
onChange,
cleanOnFocus
}: any) =>
{
const view = new List({ type: 'vertical', elementsMargin: 10 });
Expand All @@ -72,18 +74,13 @@ export const UseGraphics = ({
align,
placeholder,
value: text,
padding: [paddingTop, paddingRight, paddingBottom, paddingLeft]
padding: [paddingTop, paddingRight, paddingBottom, paddingLeft],
cleanOnFocus
});

input.onEnter.connect((val) =>
{
onChange(`Input ${i + 1} (${val})`);

input.bg = new Graphics()
.beginFill('red')
.drawRoundedRect(0, 0, width, height, radius + border)
.beginFill('green')
.drawRoundedRect(border, border, width - (border * 2), height - (border * 2), radius);
});

view.addChild(input);
Expand Down

0 comments on commit 723efc2

Please sign in to comment.