TouchScreenKeyboardKey
A class in Root.Township, the global namespace.
One key on the in-game VR touch screen keyboard. Shows its label (changing with shift), sends its key to the TouchScreenKeyboard when pressed, and repeats backspace when held. Client only.
- Listed in Global namespace: T to X
- Inherits or implements
BasicTouchScreenButton,ILabeledTouchScreenButton,ITouchScreenButton - Nested types
BackspaceActions,KeySizeType,SpecialKeySetup - Attributes
SelectionBase
Constructors
| Member | What it is |
|---|---|
TouchScreenKeyboardKey() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
Vector2 spaceButtonSize | Touch size used for the space bar. |
25 private and internal fields
| Member | What it is |
|---|---|
private float backspaceDelay | Time left before the held backspace moves to its next stage. |
private TouchScreenKeyboardKey.KeySizeType buttonType | Size class of the key (normal, suggestion or space bar), set from the key code. |
private List<UnityEvent> changes | Events to run when this key is pressed, from onPressChange. |
private float closestDistance | Squared distance of the nearest finger this frame. |
private float closestDistanceToPressSquared | Squared distance under which the key starts moving towards the finger. |
private TextRenderer completionText | Label used for word suggestion keys. |
private float continuousBackspaceDelay | Time until the next repeated backspace. |
private TouchScreenKeyboardKey.BackspaceActions currentAction | Stage of a held backspace: single, continuous or word. |
private Vector3 depressedPosition | Local position of the key cap when no finger is close. |
private Transform distancePosition | Transform moved in and out as a finger gets near. |
private Transform distanceScaling | Transform scaled by finger distance when scaleWithDistanceOn is set. Key images are also spawned under it. |
private bool isUsingSpecialSetup | Not used in this build. |
private TouchScreenKeyboardKey.SpecialKeySetup[] onPressChange | Per key code, events to invoke each time that key is pressed. |
private Material pressMaterial | Material shown while pressed. |
private Renderer pressRenderer | Renderer whose material swaps on press and release. |
private Material releasedMaterial | Material shown when released. |
private bool scaleWithDistanceOn | Scales the key by finger distance when true. |
private AnimationCurve scaleWithDistanceSquared | Curve from squared finger distance to key scale. |
private TouchScreenKeyboardKey.SpecialKeySetup[] specialSetups | Per key code, events run once at setup to change that key's look. |
private Vector2 suggestionButtonSize | Button size for suggestion keys (F5 to F8). |
private TextRenderer text | Main key label. |
private float touchDistance | Touch depth of the nearest finger, used with touchDistanceToPress. |
private AnimationCurve touchDistanceToPress | Curve from touch depth to how far the key cap moves. |
private IUnityUpdateMethod updateBackspace | Registered update method for held backspace. |
private TouchScreenKeyboard virtualKeyboard | The keyboard this key belongs to. |
Properties
| Member | What it is |
|---|---|
override Vector2 ButtonSize { get; } | Touch size of the key: the base size, the suggestion size, or the space bar size. |
2 private and internal properties
| Member | What it is |
|---|---|
private VirtualKeyInfo Info { get; set; } | Key codes (normal and shifted) this key sends. |
private TextRenderer Text { get; } | The label in use: the main text, or the completion text when the main one is hidden. |
Events
| Member | What it is |
|---|---|
event Action<bool> ShiftChanged | Shift change event declared on the key. Nothing in this class raises it. |
Methods
| Member | What it is |
|---|---|
void ApplyText(string newText) | Sets the key's label, if it differs from the current one. |
void ClearDistance() | Resets the closest finger distance before a new round of UpdateDistance calls. |
TouchScreenKeyboardKey.KeySizeType GetButtonTypeFromKeyCode(KeyCode keycode, out Vector2 size) | Size type for a key code: Space is the space bar, F5 to F8 are suggestion keys, everything else is a base key. |
string GetText() | The key's current label. |
void InitShowingSecret(GameObject hideObject) | Hides the given object unless the keyboard's current user shows secret (password) text. |
void Setup(VirtualKeyInfo info, TouchScreenKeyboard virtualKeyboard, bool? scaleWithDistance = null) | Sets the key's layout info and keyboard, applies any special setup for that key, and otherwise labels it and follows shift changes. |
void SetupDistance() | Applies the closest finger distance: scales the key if enabled and pushes it in when a finger is close enough. |
void UpdateDistance(float distanceSquared, float touchDistance) | Records a finger distance if it is closer than any seen since ClearDistance. |
protected override void InternalPress() | Sends the key (or its shift key) to the keyboard, starts the backspace repeat for backspace, and runs any on-press events. |
protected override void InternalRelease() | Restores the released material and stops the backspace repeat. |
5 private and internal methods
| Member | What it is |
|---|---|
private bool CheckForSpecialSetup(VirtualKeyInfo info) | Applies mapped function-key visuals and special setups for this key, and collects its on-press events. True if any applied. |
private void OnDestroy() | Unhooks from the keyboard's shift change and stops the backspace update. |
private void SetupCoreReferences(TouchScreenKeyboard virtualKeyboard, bool? scaleWithDistance) | Stores the keyboard, picks the key size from the key code and optionally overrides distance scaling. |
private void UpdateBackspace() | Per-frame while backspace is held: one delete, then repeated deletes, then whole-word deletes. |
private void UpdateImage(bool isShiftPressed) | Sets the label to the character for the current key, upper or lower case by shift. |
Used in
Members of other types that take, return or hold a TouchScreenKeyboardKey: