本文整理汇总了C#中FairyGUI.EventContext类的典型用法代码示例。如果您正苦于以下问题:C# EventContext类的具体用法?C# EventContext怎么用?C# EventContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventContext类属于FairyGUI命名空间,在下文中一共展示了EventContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCopy
static void OnCopy(EventContext context)
{
TextEditor te = new TextEditor();
#if (UNITY_5_3 || UNITY_5_4)
te.text = (string)context.data;
#else
te.content = new GUIContent((string)context.data);
#endif
te.OnFocus();
te.Copy();
}
示例2: OnPaste
static void OnPaste(EventContext context)
{
TextField target = (TextField)context.data;
TextEditor te = new TextEditor();
te.Paste();
#if (UNITY_5_3 || UNITY_5_4)
string value = te.text;
#else
string value = te.content.text;
#endif
if (!string.IsNullOrEmpty(value))
target.ReplaceSelection(value);
}
示例3: CallInternal
public void CallInternal(EventContext context)
{
_dispatching = true;
context.sender = owner;
try
{
if (_callback1 != null)
_callback1(context);
if (_callback0 != null)
_callback0();
}
finally
{
_dispatching = false;
}
}
示例4: CallCaptureInternal
public void CallCaptureInternal(EventContext context)
{
if (_captureCallback == null)
return;
_dispatching = true;
context.sender = owner;
try
{
_captureCallback(context);
}
finally
{
_dispatching = false;
}
}
示例5: __mouseDown
private void __mouseDown(EventContext context)
{
if (!_touchEffect)
return;
InputEvent evt = context.inputEvent;
_touchId = evt.touchId;
Vector2 pt = _owner.GlobalToLocal(new Vector2(evt.x, evt.y));
if (_tweener != null)
{
_tweener.Complete();
_tweener = null;
Stage.inst.CancelClick(_touchId);
}
_y1 = _y2 = _maskContentHolder.y;
_yOffset = pt.y - _maskContentHolder.y;
_x1 = _x2 = _maskContentHolder.x;
_xOffset = pt.x - _maskContentHolder.x;
_time1 = _time2 = Time.time;
_holdAreaPoint.x = pt.x;
_holdAreaPoint.y = pt.y;
_isHoldAreaDone = false;
_isMouseMoved = false;
_container.stage.onMouseMove.Add(__mouseMove);
_container.stage.onMouseUp.Add(__mouseUp);
}
示例6: __mouseUp
private void __mouseUp(EventContext context)
{
if (!_touchEffect)
{
_isMouseMoved = false;
return;
}
InputEvent evt = context.inputEvent;
if (_touchId != evt.touchId)
return;
_container.stage.onMouseMove.Remove(__mouseMove);
_container.stage.onMouseUp.Remove(__mouseUp);
if (!_isMouseMoved)
return;
_isMouseMoved = false;
float time = Time.time - _time2;
if (time == 0)
time = 0.001f;
float yVelocity = (_maskContentHolder.y - _y2) / time;
float xVelocity = (_maskContentHolder.x - _x2) / time;
float minDuration = _bouncebackEffect ? 0.3f : 0;
float maxDuration = 0.5f;
int overShoot = _bouncebackEffect ? 1 : 0;
float xMin = -_xOverlap, yMin = -_yOverlap;
float xMax = 0, yMax = 0;
float duration = 0f;
if (_hScroll)
ThrowTween.CalculateDuration(_maskContentHolder.x, xMin, xMax, xVelocity, overShoot, ref duration);
if (_vScroll)
ThrowTween.CalculateDuration(_maskContentHolder.y, yMin, yMax, yVelocity, overShoot, ref duration);
if (duration > maxDuration)
duration = maxDuration;
else if (duration < minDuration)
duration = minDuration;
_throwTween.start.x = _maskContentHolder.x;
_throwTween.start.y = _maskContentHolder.y;
Vector2 change1, change2;
float endX = 0, endY = 0;
if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal)
{
change1.x = ThrowTween.CalculateChange(xVelocity, duration);
change2.x = 0;
endX = _maskContentHolder.x + change1.x;
}
else
change1.x = change2.x = 0;
if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical)
{
change1.y = ThrowTween.CalculateChange(yVelocity, duration);
change2.y = 0;
endY = _maskContentHolder.y + change1.y;
}
else
change1.y = change2.y = 0;
if (_snapToItem)
{
endX = -endX / GRoot.contentScaleFactor;
endY = -endY / GRoot.contentScaleFactor;
_owner.FindObjectNear(ref endX, ref endY);
endX = -endX * GRoot.contentScaleFactor;
endY = -endY * GRoot.contentScaleFactor;
change1.x = endX - _maskContentHolder.x;
change1.y = endY - _maskContentHolder.y;
}
if (xMax < endX)
change2.x = xMax - _maskContentHolder.x - change1.x;
else if (xMin > endX)
change2.x = xMin - _maskContentHolder.x - change1.x;
if (yMax < endY)
change2.y = yMax - _maskContentHolder.y - change1.y;
else if (yMin > endY)
change2.y = yMin - _maskContentHolder.y - change1.y;
_throwTween.value = 0;
_throwTween.change1 = change1;
_throwTween.change2 = change2;
if (_tweener != null)
_tweener.Complete();
_tweener = DOTween.To(() => _throwTween.value, v => _throwTween.value = v, 1, duration)
.SetEase(Ease.OutCubic)
.OnUpdate(__tweenUpdate2)
//.........这里部分代码省略.........
示例7: __dragStart
private void __dragStart(EventContext context)
{
context.PreventDefault();
this.StartDrag((int)context.data);
}
示例8: __touchMove
void __touchMove(EventContext context)
{
if (isDisposed)
return;
if (_selectionStart == null)
return;
Vector3 v = Stage.inst.touchPosition;
v = this.GlobalToLocal(v);
if (float.IsNaN(v.x))
return;
Vector2 offset = _GetPositionOffset();
v.x += offset.x;
v.y += offset.y;
CharPosition cp = GetCharPosition(v);
if (cp.charIndex != _caretPosition)
AdjustCaret(cp);
}
示例9: __keydown
void __keydown(EventContext context)
{
if (_caret == null || context.isDefaultPrevented)
return;
InputEvent evt = context.inputEvent;
switch (evt.keyCode)
{
case KeyCode.Backspace:
{
context.PreventDefault();
if (_selectionStart != null)
{
DeleteSelection();
OnChanged();
}
else if (_caretPosition > 0)
{
int tmp = _caretPosition; //this.text 会修改_caretPosition
_caretPosition--;
this.text = _text.Substring(0, tmp - 1) + _text.Substring(tmp);
OnChanged();
}
break;
}
case KeyCode.Delete:
{
context.PreventDefault();
if (_selectionStart != null)
{
DeleteSelection();
OnChanged();
}
else if (_caretPosition < _text.Length)
{
this.text = _text.Substring(0, _caretPosition) + _text.Substring(_caretPosition + 1);
OnChanged();
}
break;
}
case KeyCode.LeftArrow:
{
context.PreventDefault();
if (evt.shift)
{
if (_selectionStart == null)
_selectionStart = GetCharPosition(_caretPosition);
}
else
ClearSelection();
if (_caretPosition > 0)
{
CharPosition cp = GetCharPosition(_caretPosition - 1);
AdjustCaret(cp);
}
break;
}
case KeyCode.RightArrow:
{
context.PreventDefault();
if (evt.shift)
{
if (_selectionStart == null)
_selectionStart = GetCharPosition(_caretPosition);
}
else
ClearSelection();
if (_caretPosition < _text.Length)
{
CharPosition cp = GetCharPosition(_caretPosition + 1);
AdjustCaret(cp);
}
break;
}
case KeyCode.UpArrow:
{
context.PreventDefault();
if (evt.shift)
{
if (_selectionStart == null)
_selectionStart = GetCharPosition(_caretPosition);
}
else
ClearSelection();
CharPosition cp = GetCharPosition(_caretPosition);
if (cp.lineIndex == 0)
return;
LineInfo line = _lines[cp.lineIndex - 1];
cp = GetCharPosition(new Vector3(_caret.cachedTransform.localPosition.x + _GetPositionOffset().x, line.y, 0));
AdjustCaret(cp);
//.........这里部分代码省略.........
示例10: __focusIn
void __focusIn(EventContext context)
{
if (_mobileInputAdapter != null)
{
OpenKeyboard();
}
else
{
_caret = Stage.inst.inputCaret;
_caret.grahpics.sortingOrder = this.renderingOrder + 1;
_caret.SetParent(cachedTransform);
_caret.SetSizeAndColor(_textFormat.size, _textFormat.color);
_highlighter = Stage.inst.highlighter;
_highlighter.grahpics.sortingOrder = this.renderingOrder + 2;
_highlighter.SetParent(cachedTransform);
_caretPosition = _text.Length;
CharPosition cp = GetCharPosition(_caretPosition);
AdjustCaret(cp);
_selectionStart = cp;
}
}
示例11: __mouseDown
private void __mouseDown(EventContext context)
{
if (this.isShowing)
{
BringToFront();
}
}
示例12: __dragStart
private void __dragStart(EventContext context)
{
context.PreventDefault();
this.StartDrag(null);
}
示例13: Return
internal static void Return(EventContext value)
{
pool.Push(value);
}
示例14: __touchBegin
void __touchBegin(EventContext context)
{
if (Stage.inst.touchCount == 2)
{
if (!_started)
{
Stage.inst.GetAllTouch(_touches);
Vector2 pt1 = _host.GlobalToLocal(Stage.inst.GetTouchPosition(_touches[0]));
Vector2 pt2 = _host.GlobalToLocal(Stage.inst.GetTouchPosition(_touches[1]));
_startDistance = Vector2.Distance(pt1, pt2);
Stage.inst.onTouchMove.Add(__touchMove);
Stage.inst.onTouchEnd.Add(__touchEnd);
}
}
}
示例15: __touchMove
void __touchMove(EventContext context)
{
InputEvent evt = context.inputEvent;
Vector2 pt1 = _host.GlobalToLocal(Stage.inst.GetTouchPosition(_touches[0]));
Vector2 pt2 = _host.GlobalToLocal(Stage.inst.GetTouchPosition(_touches[1]));
float dist = Vector2.Distance(pt1, pt2);
if (!_started && Mathf.Abs(dist - _startDistance) > UIConfig.touchDragSensitivity)
{
_started = true;
scale = 1;
_lastScale = 1;
onBegin.Call(evt);
}
if (_started)
{
float ss = dist / _startDistance;
delta = ss - _lastScale;
_lastScale = ss;
this.scale += delta;
onAction.Call(evt);
}
}