| 6 | using StereoKit; |
| 7 | |
| 8 | class DemoTextInput : ITest |
| 9 | { |
| 10 | string title = "Text Input"; |
| 11 | string description = ""; |
| 12 | |
| 13 | Pose windowPose = Demo.contentPose.Pose; |
| 14 | string text = "Edit me"; |
| 15 | string textUri = "https://stereokit.net"; |
| 16 | string number = "1"; |
| 17 | |
| 18 | public void Initialize() { } |
| 19 | public void Shutdown () { } |
| 20 | |
| 21 | public void Step() |
| 22 | { |
| 23 | UI.WindowBegin("Text Input", ref windowPose); |
| 24 | |
| 25 | UI.Text("You can specify whether or not a UI element will hide an active soft keyboard upon interaction."); |
| 26 | UI.Button("Hides active soft keyboard"); |
| 27 | UI.SameLine(); |
| 28 | UI.PushPreserveKeyboard(true); |
| 29 | UI.Button("Doesn't hide"); |
| 30 | UI.PopPreserveKeyboard(); |
| 31 | |
| 32 | UI.HSeparator(); |
| 33 | |
| 34 | UI.Text("Different TextContexts will surface different soft keyboards."); |
| 35 | Vec2 inputSize = V.XY(20*U.cm,0); |
| 36 | Vec2 labelSize = V.XY(8*U.cm,0); |
| 37 | UI.Label("Normal Text", labelSize); UI.SameLine(); UI.Input("TextText", ref text, inputSize, TextContext.Text); |
| 38 | UI.Label("URI Text", labelSize); UI.SameLine(); UI.Input("URIText", ref textUri, inputSize, TextContext.Uri); |
| 39 | UI.Label("Numeric Text", labelSize); UI.SameLine(); UI.Input("NumericText", ref number, inputSize, TextContext.Number); |
| 40 | |
| 41 | UI.HSeparator(); |
| 42 | |
| 43 | UI.Text("Soft keyboards don't show up when a physical keyboard is known to be handy! Flatscreen apps and sessions where the user has pressed physical keys recently won't show any soft keyboards."); |
| 44 | |
| 45 | bool forceKeyboard = Platform.ForceFallbackKeyboard; |
| 46 | if(UI.Toggle("Fallback Keyboard", ref forceKeyboard)) |
| 47 | Platform.ForceFallbackKeyboard = forceKeyboard; |
| 48 | |
| 49 | UI.SameLine(); |
| 50 | bool openKeyboard = Platform.KeyboardVisible; |
| 51 | if (UI.Toggle("Show Keyboard", ref openKeyboard)) |
| 52 | Platform.KeyboardShow(openKeyboard); |
| 53 | |
| 54 | UI.WindowEnd(); |
| 55 | |
| 56 | Demo.ShowSummary(title, description, new Bounds(V.XY0(0, -0.19f), V.XYZ(.4f, .5f, 0))); |
| 57 | } |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected