static void Main(string[] args) { OnScreenKeyboardWatcher watcher = new OnScreenKeyboardWatcher(); watcher.KeyboardOpened += delegate { Console.WriteLine("event fired - keyboard opened"); }; watcher.KeyboardClosed += delegate { Console.WriteLine("event fired - keyboard closed"); }; bool isOpened = OnScreenKeyboard.IsOpened(); Console.WriteLine("Was opened {0}", isOpened); OnScreenKeyboard.Show(); Thread.Sleep(5000); isOpened = OnScreenKeyboard.IsOpened(); Console.WriteLine("Now is opened {0}", isOpened); bool closed = OnScreenKeyboard.Close(); Console.WriteLine("Was closed {0}", closed); Console.ReadLine(); }
// move to the previous page in the form. public void BackPage() { OnScreenKeyboard OSK = GameObject.FindObjectOfType <OnScreenKeyboard>(); OSK.SetActive(false); for (int i = 0; i < pageList.Count; i++) { if (pageList[i].activeSelf == true) { pageIndex = i; } } //Debug.Log(pageList[pageIndex].name); pageList[pageIndex].SetActive(false); pageIndex--; // Debug.Log(pageList[pageIndex].name); pageList[pageIndex].SetActive(true); selectedPage = pageList[pageIndex].gameObject; orgPagePos = pageList[pageIndex].transform.position; System.GC.Collect(); if (pageList[pageIndex].name == "Page2") { trafficLayoutController.SetActive(true); SelectLayoutController.layoutControllerInstance.BeginLoadImages("BackPage"); } else { if (SelectLayoutController.layoutControllerInstance.isActiveAndEnabled) { SelectLayoutController.layoutControllerInstance.BeginFlushArrays(); } } }
void keyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { if (sticky != null) { string text = sticky.gameObject.name; switch (args.KeyPressed.type) { case KeyClass.Backspace: if (text.Length > 0) text = text.Substring(0, text.Length - 1); break; case KeyClass.Return: text += args.KeyPressed.ToString(); break; case KeyClass.Shift: //No need to do anything here as the keyboard will sort that on its own break; case KeyClass.String: text += args.KeyPressed.ToString(); break; } sticky.gameObject.name = text; sticky.textPointer = text.Length; sticky.StickyText = text; } }
protected void KeyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { if (ActiveField) { InputField outputText = ActiveField.input; switch (args.KeyPressed.type) { case KeyClass.Backspace: if (outputText.text.Length > 0) { outputText.text = outputText.text.Substring(0, outputText.text.Length - 1); } break; case KeyClass.Return: outputText.text += args.KeyPressed.ToString(); break; case KeyClass.Shift: //No need to do anything here as the keyboard will sort that on its own break; case KeyClass.String: if (outputText.characterLimit > 0 && outputText.text.Length >= outputText.characterLimit) { break; } outputText.text += args.KeyPressed.ToString(); break; } ActiveField.AddValues(); } }
public void Show_Should_Display_A_Keyboard() { var res = OnScreenKeyboard.Show(); Thread.Sleep(1000); // Need some timeout to be displayed res.Should().Be.True(); OnScreenKeyboard.IsVisible.Should().Be.True(); }
public void Hide_Should_Do_Nothing_When_Keybord_Is_Already_Hidden() { HideKeyboard(); var res = OnScreenKeyboard.Hide(); Thread.Sleep(1000); // Need some timeout to be destroyed res.Should().Be.False(); OnScreenKeyboard.IsVisible.Should().Be.False(); }
public void Should_Hide_A_Keyboard() { ShowKeyboard(); var res = OnScreenKeyboard.Hide(); Thread.Sleep(1000); // Need some timeout to be destroyed res.Should().Be.True(); OnScreenKeyboard.IsVisible.Should().Be.False(); }
public void Show_Should_Do_Nothing_When_Keybord_Is_Already_Displayed() { ShowKeyboard(); var res = OnScreenKeyboard.Show(); Thread.Sleep(1000); // Need some timeout to be displayed // res.Should().Be.False(); OnScreenKeyboard.IsVisible.Should().Be.True(); }
public Game() { text = ""; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 400; IsMouseVisible = true; Content.RootDirectory = "Content"; onScreenKeyboard = new OnScreenKeyboard(this); Components.Add(onScreenKeyboard); }
// Token: 0x06006382 RID: 25474 RVA: 0x002358FC File Offset: 0x00233CFC private void KeyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { switch (args.KeyPressed.type) { case KeyClass.String: if (this.mWasJustFocused) { this.UnfocusInput(); this.popupInputField.text = args.KeyPressed.ToString(); this.inputtedKeyCodes.Add(args.KeyPressed.keyCode); } else { InputField inputField = this.popupInputField; inputField.text += args.KeyPressed.ToString(); this.inputtedKeyCodes.Add(args.KeyPressed.keyCode); } this.popupInputField.MoveTextEnd(false); break; case KeyClass.Shift: this.UnfocusInput(); break; case KeyClass.Return: { InputField inputField2 = this.popupInputField; inputField2.text += args.KeyPressed.ToString(); this.inputtedKeyCodes.Add(args.KeyPressed.keyCode); break; } case KeyClass.Backspace: if (this.mWasJustFocused) { this.UnfocusInput(); this.popupInputField.text = string.Empty; this.inputtedKeyCodes.Clear(); } else if (this.popupInputField.text.Length > 0) { this.popupInputField.text = this.popupInputField.text.Substring(0, this.popupInputField.text.Length - 1); this.inputtedKeyCodes.RemoveAt(this.inputtedKeyCodes.Count - 1); } break; } if (this.popupInputField.isFocused && !Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && Input.anyKeyDown) { this.UnfocusInput(); } }
void InitKeyboardPanel() { if (!GameControl.instance.isMobile) { return; } OnScreenKeyboard keyboardPanel = Instantiate(Resources.Load("HomeScreen/OnScreenKeyboard", typeof(OnScreenKeyboard))) as OnScreenKeyboard; keyboardPanel.gameObject.SetActive(false); keyboardPanel.transform.SetParent(_stage.transform, false); KeyboardController.Instance().keyboard = keyboardPanel; }
public override void Initialize() { for (int x = 0; x < Core.Players.Count(); x++) { _cursorPositions[x] = CursorPosition.NotJoined; Core.Players[x].Playing = false; Core.Players[x].Remote = false; Core.Players[x].PlayerOptions = new PlayerOptions(); Core.Players[x].Profile = null; CreatePlayerMenu(x); CreateProfileMenu(x); Core.Players[x].Team = 0; _infoMessages[x] = ""; _keyboards[x] = new OnScreenKeyboard { MaxLength = 10, Id = x, Position = (Core.Metrics["OnScreenKeyboard", x]), Width = 640 }; _keyboards[x].EntryCancelled += Keyboard_EntryCancelled; _keyboards[x].EntryComplete += Keyboard_EntryComplete; } _playerOptionsSet = new PlayerOptionsSet { Players = Core.Players, Positions = Core.Metrics["NewGamePlayerOptionsFrames"], DrawAttract = false, Size = Core.Metrics["PlayerOptionsFrame.Size", 0] }; _playerOptionsSet.CreatePlayerOptionsFrames(); //Join the player that pressed START to enter this screen automatically. if (Core.Cookies.ContainsKey("JoiningPlayer")) { var player = (int)Core.Cookies["JoiningPlayer"]; StartPressed(player); Core.Cookies.Remove("JoiningPlayer"); } InitSprites(); base.Initialize(); }
void keyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { switch (args.KeyPressed.type) { case KeyClass.Backspace: if(outputText.text.Length > 0) outputText.text = outputText.text.Substring(0, outputText.text.Length -1); break; case KeyClass.Return: outputText.text += args.KeyPressed.ToString(); break; case KeyClass.Shift: //No need to do anything here as the keyboard will sort that on its own break; case KeyClass.String: outputText.text += args.KeyPressed.ToString(); break; } }
void OnKeyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { // print ("OnKeyboardKeyPressed.type: " + args.KeyPressed.type); if (_disableKeyboard) { return; } if (GameControl.instance.isMobile && _searchInputButtonText.text == _inputMessage) { _searchInputButtonText.text = ""; } switch (args.KeyPressed.type) { case KeyClass.Backspace: if (_searchInputButtonText.text.Length > 0) { _disableKeyboard = true; _searchInputButtonText.text = _searchInputButtonText.text.Substring(0, _searchInputButtonText.text.Length - 1); Search(_searchInputButtonText.text); } break; case KeyClass.Return: OnSearchButtonClick(); break; case KeyClass.Shift: break; case KeyClass.String: _searchInputButtonText.text += args.KeyPressed.ToString(); Search(_searchInputButtonText.text); break; } }
// Use this for initialization void Start() { lefGripperDraggable = left_gripper_drag_visual.GetComponent <HandDraggableCustom>(); GameObject ActionNameObject = left_gripper_state_display_target.transform.Find("ActionName").gameObject; actionNameText = ActionNameObject.GetComponent <Text>(); actionNameButton = ActionNameObject.GetComponent <Button>(); onScreenKeyboard = GetComponent <OnScreenKeyboard>(); // plannerInventory = plannerCanvas.GetComponent<Inventory>(); actionNameButton.onClick.AddListener(changeActionName); if (lefGripperDraggable == null) { Debug.Log("cannot find draggable"); } lefGripperDraggable.IsDraggingEnabled = false; left_gripper_state_display_target.SetActive(false); leftGripperOriginalCollider = left_gripper_original.transform.Find("gripper_open").GetComponent <BoxCollider>(); }
void keyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { switch (args.KeyPressed.type) { case KeyClass.Backspace: if (outputText.text.Length > 0) { outputText.text = outputText.text.Substring(0, outputText.text.Length - 1); } break; case KeyClass.Return: outputText.text += args.KeyPressed.ToString(); break; case KeyClass.Shift: //No need to do anything here as the keyboard will sort that on its own break; case KeyClass.String: outputText.text += args.KeyPressed.ToString(); break; } }
public override void OnInspectorGUI() { if (RowStructure.Count == 0) { //Default a QWERTY in GenerateQWERTY(); } //Cast our target pointer OnScreenKeyboard subject = target as OnScreenKeyboard; DrawDefaultInspector(); //If we have a key template populated show the button if (subject.KeyTemplate != null) { showBuilder = EditorGUILayout.Foldout(showBuilder, "Keyboard Builder"); if (showBuilder) { EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Row Count: "); RowsToBuild = EditorGUILayout.FloatField(RowsToBuild); if (RowsToBuild < 1) { RowsToBuild = 1; } EditorGUILayout.EndHorizontal(); //Manage the row structure if (RowsToBuild > RowStructure.Count) { for (int i = 0; i < RowsToBuild; i++) { if (i >= RowStructure.Count) { RowStructure.Add(new OnScreenKeyboardRowBuilder()); } } } if (RowsToBuild < RowStructure.Count) { List <OnScreenKeyboardRowBuilder> nBuilders = new List <OnScreenKeyboardRowBuilder>(); for (int i = 0; i < RowsToBuild; i++) { nBuilders.Add(RowStructure[i]); } RowStructure = nBuilders; } //Render the inputs for each row structure for (int i = 0; i < RowStructure.Count; i++) { if (RowStructure[i] == null) { RowStructure[i] = new OnScreenKeyboardRowBuilder(); } //EditorGUILayout.LabelField("Row: " + (i+1).ToString(), EditorStyles.boldLabel); RowStructure[i].FoldOut = EditorGUILayout.Foldout(RowStructure[i].FoldOut, "Row: " + (i + 1).ToString()); if (RowStructure[i].FoldOut) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Key Count: "); RowStructure[i].keyCount = EditorGUILayout.IntField(RowStructure[i].keyCount); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Key Spacing: "); RowStructure[i].KeyShiftHorizontal = EditorGUILayout.FloatField(RowStructure[i].KeyShiftHorizontal); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Row Offset: "); RowStructure[i].RowShiftHorizontal = EditorGUILayout.FloatField(RowStructure[i].RowShiftHorizontal); EditorGUILayout.EndHorizontal(); for (int ii = 0; ii < RowStructure[i].keyCount; ii++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Type: ", GUILayout.MinWidth(25)); if (ii >= RowStructure[i].types.Count) { RowStructure[i].types.Add(KeyClass.String); } RowStructure[i].types[ii] = (KeyClass)System.Enum.Parse(typeof(KeyClass), EditorGUILayout.EnumPopup(RowStructure[i].types[ii]).ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Upper: ", GUILayout.MinWidth(25)); if (ii >= RowStructure[i].upperValues.Count) { RowStructure[i].upperValues.Add("A"); } RowStructure[i].upperValues[ii] = EditorGUILayout.TextField(RowStructure[i].upperValues[ii]); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Lower: ", GUILayout.MinWidth(25)); if (ii >= RowStructure[i].lowerValues.Count) { RowStructure[i].lowerValues.Add("a"); } RowStructure[i].lowerValues[ii] = EditorGUILayout.TextField(RowStructure[i].lowerValues[ii]); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); } } } if (GUILayout.Button("Template QWERTY")) { GenerateQWERTY(); } if (GUILayout.Button("Template AZERTY")) { GenerateAZERTY(); } if (GUILayout.Button("Generate Objects")) { GenerateObjects(subject); } EditorGUILayout.EndVertical(); } } }
private void GenerateObjects(OnScreenKeyboard subject) { //Before we start to loop and create lets create a root object so we can shift the keyboard keys as a set easily if (lastRootBuilt != null) { GameObject.DestroyImmediate(lastRootBuilt); } lastRootBuilt = new GameObject("Keys"); //Now we apply this to our keyboard and center lastRootBuilt.transform.parent = subject.gameObject.transform; lastRootBuilt.transform.localPosition = Vector3.zero; List <OnScreenKeyboardKey[]> RowsBuilt = new List <OnScreenKeyboardKey[]>(); int rowCounter = 0; foreach (OnScreenKeyboardRowBuilder builder in RowStructure) { OnScreenKeyboardKey[] nRow = GenerateKeys(rowCounter, lastRootBuilt, builder, subject.KeyTemplate); RowsBuilt.Add(nRow); rowCounter++; } //Once we have them all built we need to link the up and down navigations int rowIndex = 0; foreach (OnScreenKeyboardKey[] row in RowsBuilt) { int PreviousRow = rowIndex - 1; int NextRow = rowIndex + 1; if (NextRow >= RowsBuilt.Count) { NextRow = 0; } if (PreviousRow < 0) { PreviousRow = RowsBuilt.Count - 1; } for (int i = 0; i < row.Length; i++) { //row upper link to previous row if (i < RowsBuilt[PreviousRow].Length) { row[i].UpKey = RowsBuilt[PreviousRow][i]; } else { row[i].UpKey = RowsBuilt[PreviousRow][RowsBuilt[PreviousRow].Length - 1]; } //row lower link to next row if (i < RowsBuilt[NextRow].Length) { row[i].DownKey = RowsBuilt[NextRow][i]; } else { row[i].DownKey = RowsBuilt[NextRow][RowsBuilt[NextRow].Length - 1]; } } rowIndex++; } //Finnaly we want to update the OnScreenKeyboard structure to render the results subject.UpdateStructure(); }
private void BtnKeyboardClick(object sender, RoutedEventArgs e) { OnScreenKeyboard.StartOsk(this); }
private void GenerateObjects(OnScreenKeyboard subject) { //Before we start to loop and create lets create a root object so we can shift the keyboard keys as a set easily if (lastRootBuilt != null) { GameObject.DestroyImmediate(lastRootBuilt); } lastRootBuilt = new GameObject("Keys", typeof(UnityEngine.UI.VerticalLayoutGroup)); lastRootBuilt.transform.SetParent(subject.gameObject.transform, false); RectTransform rTrans = lastRootBuilt.GetComponent <RectTransform>(); rTrans.anchorMax = Vector2.one; rTrans.anchorMin = Vector2.zero; rTrans.anchoredPosition = Vector2.zero; rTrans.sizeDelta = Vector2.zero; List <OnScreenKeyboardKey[]> RowsBuilt = new List <OnScreenKeyboardKey[]>(); int rowCounter = 0; foreach (OnScreenKeyboardRowBuilder builder in RowStructure) { GameObject rowRoot = new GameObject("Row " + (rowCounter + 1).ToString(), typeof(UnityEngine.UI.HorizontalLayoutGroup)); rowRoot.transform.parent = lastRootBuilt.transform; rowRoot.transform.localPosition = Vector3.zero; rowRoot.transform.localEulerAngles = Vector3.zero; OnScreenKeyboardKey[] nRow = GenerateKeys(rowCounter, rowRoot, builder, subject.KeyTemplate); RowsBuilt.Add(nRow); rowCounter++; } //Once we have them all built we need to link the up and down navigations int rowIndex = 0; foreach (OnScreenKeyboardKey[] row in RowsBuilt) { int PreviousRow = rowIndex - 1; int NextRow = rowIndex + 1; if (NextRow >= RowsBuilt.Count) { NextRow = 0; } if (PreviousRow < 0) { PreviousRow = RowsBuilt.Count - 1; } for (int i = 0; i < row.Length; i++) { UnityEngine.UI.Navigation navPointer = row[i].GetComponent <UnityEngine.UI.Button>().navigation; //row upper link to previous row if (i < RowsBuilt[PreviousRow].Length) { navPointer.selectOnUp = RowsBuilt[PreviousRow][i].GetComponent <UnityEngine.UI.Button>(); //row[i].UpKey = RowsBuilt[PreviousRow][i]; } else { navPointer.selectOnUp = RowsBuilt[PreviousRow][RowsBuilt[PreviousRow].Length - 1].GetComponent <UnityEngine.UI.Button>(); //row[i].UpKey = RowsBuilt[PreviousRow][RowsBuilt[PreviousRow].Length-1]; } //row lower link to next row if (i < RowsBuilt[NextRow].Length) { navPointer.selectOnDown = RowsBuilt[NextRow][i].GetComponent <UnityEngine.UI.Button>(); //row[i].DownKey = RowsBuilt[NextRow][i]; } else { navPointer.selectOnDown = RowsBuilt[NextRow][RowsBuilt[NextRow].Length - 1].GetComponent <UnityEngine.UI.Button>(); //row[i].DownKey = RowsBuilt[NextRow][RowsBuilt[NextRow].Length-1]; } row[i].GetComponent <UnityEngine.UI.Button>().navigation = navPointer; } rowIndex++; } //Finnaly we want to update the OnScreenKeyboard structure to render the results subject.UpdateStructure(); }
private static void Element_TouchUp(object sender, TouchEventArgs e) { OnScreenKeyboard.Show(); }
protected void KeyboardKeyPressed(OnScreenKeyboard sender, OnScreenKeyboardArguments args) { if (ActiveField) { int caretPos; InputField outputText = ActiveField.input; switch (args.KeyPressed.type) { case KeyClass.Backspace: if (outputText.text.Length > 0 || outputText.caretPosition > 0) { caretPos = outputText.caretPosition; outputText.text = outputText.text.Remove(outputText.caretPosition - 1, 1); outputText.caretPosition = caretPos - 1; } break; case KeyClass.Return: outputText.text += args.KeyPressed.ToString(); break; case KeyClass.Shift: //No need to do anything here as the keyboard will sort that on its own break; case KeyClass.String: if (outputText.characterLimit > 0 && outputText.text.Length >= outputText.characterLimit) { break; } caretPos = outputText.caretPosition; string s = outputText.text; outputText.text = outputText.text.Insert(outputText.caretPosition, args.KeyPressed.ToString()); outputText.caretPosition = caretPos + 1; break; case KeyClass.ModifySix: if (outputText.characterLimit > 0 && outputText.text.Length >= outputText.characterLimit) { break; } caretPos = outputText.caretPosition; string x = outputText.text; outputText.text = outputText.text.Insert(outputText.caretPosition, args.KeyPressed.ToString()); outputText.caretPosition = caretPos + 6; break; case KeyClass.ModifyEight: if (outputText.characterLimit > 0 && outputText.text.Length >= outputText.characterLimit) { break; } caretPos = outputText.caretPosition; string z = outputText.text; outputText.text = outputText.text.Insert(outputText.caretPosition, args.KeyPressed.ToString()); outputText.caretPosition = caretPos + 8; break; case KeyClass.ModifyFor: if (outputText.characterLimit > 0 && outputText.text.Length >= outputText.characterLimit) { break; } caretPos = outputText.caretPosition; string w = outputText.text; outputText.text = outputText.text.Insert(outputText.caretPosition, args.KeyPressed.ToString()); outputText.caretPosition = caretPos + 4; break; case KeyClass.ModifyTree: if (outputText.characterLimit > 0 && outputText.text.Length >= outputText.characterLimit) { break; } caretPos = outputText.caretPosition; string o = outputText.text; outputText.text = outputText.text.Insert(outputText.caretPosition, args.KeyPressed.ToString()); outputText.caretPosition = caretPos + 3; break; } ActiveField.AddValues(); } }