Пример #1
0
        protected internal override void OnSemanticInputEvent(SemanticEventArgs e)
        {
            if (IsDisabled())
            {
                return;
            }

            if (e.d_semanticValue == SemanticValue.SV_Confirm)
            {
                OnClicked(e);

                ++e.handled;
            }
        }
Пример #2
0
        protected internal override void OnSemanticInputEvent(SemanticEventArgs e)
        {
            if (e.d_semanticValue == SemanticValue.SV_SelectRange ||
                e.d_semanticValue == SemanticValue.SV_SelectCumulative)
            {
                HandleSelection(GetGUIContext().GetCursor().GetPosition(),
                                true, d_isMultiSelectEnabled, e.d_semanticValue == SemanticValue.SV_SelectRange);
            }

            HandleSelectionNavigation(e);

            ++e.handled;
            base.OnSemanticInputEvent(e);
        }
Пример #3
0
        protected internal override void OnSemanticInputEvent(SemanticEventArgs e)
        {
            var rangeSelection      = e.d_semanticValue == SemanticValue.SV_SelectRange;
            var cumulativeSelection = e.d_semanticValue == SemanticValue.SV_SelectCumulative;

            if (_selectable &&
                (e.d_semanticValue == SemanticValue.SV_CursorActivate || rangeSelection || cumulativeSelection) &&
                e.d_payload.source == CursorInputSource.Left)
            {
                if (OwnerList != null)
                {
                    OwnerList.NotifyItemActivated(this, cumulativeSelection, rangeSelection);
                }
                else
                {
                    SetSelected(!IsSelected());
                }
                ++e.handled;
            }
        }
Пример #4
0
        protected void HandleSelectionNavigation(SemanticEventArgs e)
        {
            var parentIndex         = d_itemModel.GetRootIndex();
            var lastSelectedChildId = -1;

            if (d_indexSelectionStates.Count != 0)
            {
                var lastSelection = d_indexSelectionStates.Last();
                lastSelectedChildId = lastSelection.d_childId;
                parentIndex         = lastSelection.d_parentIndex;
            }

            var childrenCount = d_itemModel.GetChildCount(parentIndex);

            if (childrenCount == 0)
            {
                return;
            }

            var nextSelectedChildId = lastSelectedChildId;

            if (e.d_semanticValue == SemanticValue.SV_GoDown)
            {
                nextSelectedChildId = Math.Min(nextSelectedChildId + 1, childrenCount - 1);
            }
            else if (e.d_semanticValue == SemanticValue.SV_GoUp)
            {
                nextSelectedChildId = Math.Max(0, nextSelectedChildId - 1);
            }

            if (nextSelectedChildId == -1 ||
                nextSelectedChildId == lastSelectedChildId)
            {
                return;
            }

            SetSelectedIndex(d_itemModel.MakeIndex(nextSelectedChildId, parentIndex));
        }
Пример #5
0
        // Overridden event handlers

        protected internal override void OnSemanticInputEvent(SemanticEventArgs e)
        {
            if (IsDisabled())
            {
                return;
            }

            if (e.d_semanticValue == SemanticValue.SV_SelectAll && e.d_payload.source == CursorInputSource.Left)
            {
                _dragAnchorIdx = 0;
                SetCaretIndex(GetText().Length);
                SetSelection(_dragAnchorIdx, _caretPos);
                ++e.handled;
            }
            else if (e.d_semanticValue == SemanticValue.SV_SelectWord && e.d_payload.source == CursorInputSource.Left)
            {
                // if masked, set up to select all
                if (IsTextMaskingEnabled())
                {
                    _dragAnchorIdx = 0;
                    SetCaretIndex(GetText().Length);
                }
                // not masked, so select the word that was double-clicked.
                else
                {
                    _dragAnchorIdx = TextUtils.GetWordStartIdx(GetText(),
                                                               _caretPos == GetText().Length ? _caretPos : _caretPos + 1);
                    _caretPos = TextUtils.GetNextWordStartIdx(GetText(), _caretPos);
                }

                // perform actual selection operation.
                SetSelection(_dragAnchorIdx, _caretPos);

                ++e.handled;
            }

            if (e.handled == 0 && HasInputFocus())
            {
                if (IsReadOnly())
                {
                    base.OnSemanticInputEvent(e);
                    return;
                }

                if (GetSelectionLength() == 0 && IsSelectionSemanticValue(e.d_semanticValue))
                {
                    _dragAnchorIdx = _caretPos;
                }

                // Check if the semantic value to be handled is of a general type and can thus be
                // handled via common EditboxBase handlers
                var isSemanticValueHandled = HandleBasicSemanticValue(e);

                // If the semantic value was not handled, check for specific values
                if (!isSemanticValueHandled)
                {
                    // We assume it will be handled now, if not it will be set to false in default-case
                    isSemanticValueHandled = true;

                    switch (e.d_semanticValue)
                    {
                    case SemanticValue.SV_Confirm:
                    {
                        // Fire 'input accepted' event
                        OnTextAcceptedEvent(new WindowEventArgs(this));
                        break;
                    }

                    case SemanticValue.SV_GoToStartOfLine:
                        HandleHome(false);
                        break;

                    case SemanticValue.SV_GoToEndOfLine:
                        HandleEnd(false);
                        break;

                    case SemanticValue.SV_SelectToStartOfLine:
                        HandleHome(true);
                        break;

                    case SemanticValue.SV_SelectToEndOfLine:
                        HandleEnd(true);
                        break;

                    default:
                        base.OnSemanticInputEvent(e);
                        isSemanticValueHandled = false;
                        break;
                    }
                }

                if (isSemanticValueHandled)
                {
                    ++e.handled;
                }
            }
        }
Пример #6
0
        public bool HandleBasicSemanticValue(SemanticEventArgs e)
        {
            switch (e.d_semanticValue)
            {
            case SemanticValue.SV_DeletePreviousCharacter:
                HandleBackspace();
                break;

            case SemanticValue.SV_DeleteNextCharacter:
                HandleDelete();
                break;

            case SemanticValue.SV_GoToPreviousCharacter:
                HandleCharLeft(false);
                break;

            case SemanticValue.SV_GoToNextCharacter:
                HandleCharRight(false);
                break;

            case SemanticValue.SV_SelectPreviousCharacter:
                HandleCharLeft(true);
                break;

            case SemanticValue.SV_SelectNextCharacter:
                HandleCharRight(true);
                break;

            case SemanticValue.SV_GoToPreviousWord:
                HandleWordLeft(false);
                break;

            case SemanticValue.SV_GoToNextWord:
                HandleWordRight(false);
                break;

            case SemanticValue.SV_SelectPreviousWord:
                HandleWordLeft(true);
                break;

            case SemanticValue.SV_SelectNextWord:
                HandleWordRight(true);
                break;

            case SemanticValue.SV_GoToStartOfDocument:
                HandleHome(false);
                break;

            case SemanticValue.SV_GoToEndOfDocument:
                HandleEnd(false);
                break;

            case SemanticValue.SV_SelectToStartOfDocument:
                HandleHome(true);
                break;

            case SemanticValue.SV_SelectToEndOfDocument:
                HandleEnd(true);
                break;

            case SemanticValue.SV_SelectAll:
                HandleSelectAll();
                break;

            default:
                return(false);
            }

            return(true);
        }