void __focusIn(EventContext context) { if (!editable || !Application.isPlaying) { return; } _editing = true; if (_caret == null) { CreateCaret(); } if (!string.IsNullOrEmpty(_promptText)) { UpdateText(); } float caretSize; //如果界面缩小过,光标很容易看不见,这里放大一下 if (UIConfig.inputCaretSize == 1 && GRoot.contentScaleFactor < 1) { caretSize = (float)UIConfig.inputCaretSize / GRoot.contentScaleFactor; } else { caretSize = UIConfig.inputCaretSize; } _caret.SetSize(caretSize, textField.textFormat.size); _caret.DrawRect(0, Color.clear, textField.textFormat.color); AddChild(_caret); _selectionShape.Clear(); AddChild(_selectionShape); if (!textField.Redraw()) { TextField.CharPosition cp = GetCharPosition(_caretPosition); AdjustCaret(cp); } if (Stage.keyboardInput) { if (keyboardInput) { Stage.inst.OpenKeyboard(_text, false, _displayAsPassword ? false : !textField.singleLine, _displayAsPassword, false, null, keyboardType, hideInput); SetSelection(0, -1); } } else { Input.imeCompositionMode = IMECompositionMode.On; _composing = 0; } }
static public int DrawRect(IntPtr l) { try { FairyGUI.Shape self = (FairyGUI.Shape)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Color a2; checkType(l, 3, out a2); UnityEngine.Color a3; checkType(l, 4, out a3); self.DrawRect(a1, a2, a3); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
void __focusIn(EventContext context) { if (!editable) { return; } _editing = true; if (_caret == null) { CreateCaret(); } if (!string.IsNullOrEmpty(_promptText)) { UpdateText(); } float caretSize = UIConfig.inputCaretSize; _caret.SetSize(caretSize, textField.textFormat.size); _caret.DrawRect(0, Color.Transparent, textField.textFormat.color); AddChild(_caret); _selectionShape.Clear(); AddChild(_selectionShape); if (!textField.Rebuild()) { TextField.CharPosition cp = GetCharPosition(_caretPosition); AdjustCaret(cp); } IMEAdapter.compositionMode = IMEAdapter.CompositionMode.On; _composing = 0; }
void __focusIn(EventContext context) { if (!Application.isPlaying) { return; } _editing = true; _textBeforeEdit = _text; if (_caret == null) { CreateCaret(); } if (!string.IsNullOrEmpty(_promptText)) { UpdateText(); } float caretSize; //如果界面缩小过,光标很容易看不见,这里放大一下 if (UIConfig.inputCaretSize == 1 && UIContentScaler.scaleFactor < 1) { caretSize = UIConfig.inputCaretSize / UIContentScaler.scaleFactor; } else { caretSize = UIConfig.inputCaretSize; } _caret.SetSize(caretSize, textField.textFormat.size); _caret.DrawRect(0, Color.clear, textField.textFormat.color); _caret.visible = _editable; AddChild(_caret); _selectionShape.Clear(); AddChildAt(_selectionShape, 0); if (!textField.Redraw()) { TextField.CharPosition cp = GetCharPosition(_caretPosition); AdjustCaret(cp); } if (Stage.keyboardInput) { if (keyboardInput) { Stage.inst.OpenKeyboard(_text, false, _displayAsPassword ? false : !textField.singleLine, _displayAsPassword, false, null, keyboardType, hideInput); SetSelection(0, -1); } } else { if (!disableIME) { Input.imeCompositionMode = IMECompositionMode.On; } else { Input.imeCompositionMode = IMECompositionMode.Off; } _composing = 0; if ((string)context.data == "key") //select all if got focus by tab key { SetSelection(0, -1); } TextInputHistory.inst.StartRecord(this); } }
/// <summary> /// Draw a rectangle. /// 画矩形。 /// </summary> /// <param name="aWidth">Width</param> /// <param name="aHeight">Height</param> /// <param name="lineSize">Line size</param> /// <param name="lineColor">Line color</param> /// <param name="fillColor">Fill color</param> public void DrawRect(float aWidth, float aHeight, int lineSize, Color lineColor, Color fillColor) { this.SetSize(aWidth, aHeight); _shape.DrawRect(lineSize, lineColor, fillColor); }