本文整理汇总了C#中FairyGUI.EventContext.PreventDefault方法的典型用法代码示例。如果您正苦于以下问题:C# EventContext.PreventDefault方法的具体用法?C# EventContext.PreventDefault怎么用?C# EventContext.PreventDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FairyGUI.EventContext
的用法示例。
在下文中一共展示了EventContext.PreventDefault方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: __dragStart
private void __dragStart(EventContext context)
{
context.PreventDefault();
this.StartDrag((int)context.data);
}
示例2: __dragStart
private void __dragStart(EventContext context)
{
context.PreventDefault();
this.StartDrag(null);
}
示例3: __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);
//.........这里部分代码省略.........
示例4: __keydown
void __keydown(EventContext context)
{
if (!_editing || context.isDefaultPrevented)
return;
InputEvent evt = context.inputEvent;
switch (evt.keyCode)
{
case KeyCode.Backspace:
{
context.PreventDefault();
if (_selectionStart != null)
ReplaceSelection(null);
else if (_caretPosition > 0)
{
int tmp = _caretPosition;
_caretPosition--;
ReplaceText(textField.text.Substring(0, tmp - 1) + textField.text.Substring(tmp));
}
break;
}
case KeyCode.Delete:
{
context.PreventDefault();
if (_selectionStart != null)
ReplaceSelection(null);
else if (_caretPosition < textField.text.Length)
ReplaceText(textField.text.Substring(0, _caretPosition) + textField.text.Substring(_caretPosition + 1));
break;
}
case KeyCode.LeftArrow:
{
context.PreventDefault();
if (evt.shift)
{
if (_selectionStart == null)
_selectionStart = GetCharPosition(_caretPosition);
}
else
ClearSelection();
if (_caretPosition > 0)
{
TextField.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 < textField.text.Length)
{
TextField.CharPosition cp = GetCharPosition(_caretPosition + 1);
AdjustCaret(cp);
}
break;
}
case KeyCode.UpArrow:
{
context.PreventDefault();
if (evt.shift)
{
if (_selectionStart == null)
_selectionStart = GetCharPosition(_caretPosition);
}
else
ClearSelection();
TextField.CharPosition cp = GetCharPosition(_caretPosition);
if (cp.lineIndex == 0)
return;
TextField.LineInfo line = textField.lines[cp.lineIndex - 1];
cp = GetCharPosition(new Vector2(_caret.x, line.y + textField.y));
AdjustCaret(cp);
break;
}
case KeyCode.DownArrow:
{
context.PreventDefault();
if (evt.shift)
{
if (_selectionStart == null)
_selectionStart = GetCharPosition(_caretPosition);
}
//.........这里部分代码省略.........