Skip to content

Commit

Permalink
add InputTextArea support for VirtualKeyboard (#12746)
Browse files Browse the repository at this point in the history
  • Loading branch information
ycaptain committed Jul 14, 2022
1 parent 2dc3628 commit c63ca23
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/dev/gui/src/2D/controls/virtualKeyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { TextBlock } from "./textBlock";
import type { InputText } from "./inputText";
import { RegisterClass } from "core/Misc/typeStore";
import type { AdvancedDynamicTexture } from "../advancedDynamicTexture";
import { InputTextArea } from "./inputTextArea";

/**
* Class used to store key control properties
Expand Down Expand Up @@ -169,12 +170,12 @@ export class VirtualKeyboard extends StackPanel {
}
}

private _currentlyConnectedInputText: Nullable<InputText> = null;
private _currentlyConnectedInputText: Nullable<InputText | InputTextArea> = null;
private _connectedInputTexts: ConnectedInputText[] = [];
private _onKeyPressObserver: Nullable<Observer<string>> = null;

/** Gets the input text control currently attached to the keyboard */
public get connectedInputText(): Nullable<InputText> {
public get connectedInputText(): Nullable<InputText | InputTextArea> {
return this._currentlyConnectedInputText;
}

Expand Down Expand Up @@ -206,13 +207,25 @@ export class VirtualKeyboard extends StackPanel {
this.applyShiftState(this.shiftState);
return;
case "\u2190":
this._currentlyConnectedInputText.processKey(8);
if (this._currentlyConnectedInputText instanceof InputTextArea) {
this._currentlyConnectedInputText.alternativeProcessKey("Backspace");
} else {
this._currentlyConnectedInputText.processKey(8);
}
return;
case "\u21B5":
this._currentlyConnectedInputText.processKey(13);
if (this._currentlyConnectedInputText instanceof InputTextArea) {
this._currentlyConnectedInputText.alternativeProcessKey("Enter");
} else {
this._currentlyConnectedInputText.processKey(13);
}
return;
}
this._currentlyConnectedInputText.processKey(-1, this.shiftState ? key.toUpperCase() : key);
if (this._currentlyConnectedInputText instanceof InputTextArea) {
this._currentlyConnectedInputText.alternativeProcessKey("", this.shiftState ? key.toUpperCase() : key);
} else {
this._currentlyConnectedInputText.processKey(-1, this.shiftState ? key.toUpperCase() : key);
}

if (this.shiftState === 1) {
this.shiftState = 0;
Expand Down

0 comments on commit c63ca23

Please sign in to comment.