当前位置: 首页>>代码示例>>C#>>正文


C# EventContext.PreventDefault方法代码示例

本文整理汇总了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);
        }
开发者ID:kensong1194717296,项目名称:FairyGUI-unity,代码行数:6,代码来源:Window.cs

示例2: __dragStart

        private void __dragStart(EventContext context)
        {
            context.PreventDefault();

            this.StartDrag(null);
        }
开发者ID:wwxx,项目名称:FairyGUI-unity,代码行数:6,代码来源:Window.cs

示例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);
//.........这里部分代码省略.........
开发者ID:kensong1194717296,项目名称:FairyGUI-unity,代码行数:101,代码来源:TextField.cs

示例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);
                        }
//.........这里部分代码省略.........
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:101,代码来源:InputTextField.cs


注:本文中的FairyGUI.EventContext.PreventDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。