Exemplo n.º 1
0
        private bool handleCursorMoveEvent(SemanticInputEvent @event)
        {
            var new_position = new Lunatics.Mathematics.Vector2(
                @event.d_payload.array[0],
                @event.d_payload.array[1]);

            // setup cursor movement event args object.
            var ciea = new CursorInputEventArgs(null);

            ciea.moveDelta = new_position - _cursor.GetPosition();

            // no movement means no event
            if ((ciea.moveDelta.X == 0) && (ciea.moveDelta.Y == 0))
            {
                return(false);
            }

            ciea.scroll = 0;
            ciea.Source = CursorInputSource.None;
            ciea.state  = d_cursorsState;

            // move cursor to new position
            _cursor.SetPosition(new_position);
            // update position in args (since actual position may be constrained)
            ciea.Position = _cursor.GetPosition();

            return(HandleCursorMoveImpl(ciea));
        }
Exemplo n.º 2
0
        private bool handleCursorActivateEvent(SemanticInputEvent @event)
        {
            var ciea = new CursorInputEventArgs(null);

            ciea.Position  = _cursor.GetPosition();
            ciea.moveDelta = Lunatics.Mathematics.Vector2.Zero;
            ciea.Source    = @event.d_payload.source;
            ciea.scroll    = 0;
            ciea.Window    = GetTargetWindow(ciea.Position, false);
            // make cursor position sane for this target window
            if (ciea.Window != null)
            {
                ciea.Position = ciea.Window.GetUnprojectedPosition(ciea.Position);
            }

            // if there is no target window, input can not be handled.
            if (ciea.Window == null)
            {
                return(false);
            }

            if (d_windowNavigator != null)
            {
                d_windowNavigator.SetCurrentFocusedWindow(ciea.Window);
            }

            ciea.Window.OnCursorActivate(ciea);
            return(ciea.handled != 0);
        }
Exemplo n.º 3
0
        private bool HandleSemanticInputEvent(SemanticInputEvent @event)
        {
            if (d_semanticEventHandlers.ContainsKey(@event.d_value))
            {
                return(d_semanticEventHandlers[@event.d_value](@event));
            }

            var targetWindow = GetInputTargetWindow();

            // window navigator's window takes precedence
            if (d_windowNavigator != null)
            {
                targetWindow = d_windowNavigator.GetCurrentFocusedWindow();
            }

            if (targetWindow != null)
            {
                var args = new SemanticEventArgs(targetWindow);

                args.d_payload       = @event.d_payload;
                args.d_semanticValue = (SemanticValue)@event.d_value;

                args.Window.OnSemanticInputEvent(args);

                return(args.handled != 0);
            }

            return(false);
        }
Exemplo n.º 4
0
        public virtual bool InjectMouseLeaves()
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            var semanticEvent = new SemanticInputEvent((int)SemanticValue.SV_PointerLeave);

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 5
0
        public virtual bool InjectMouseButtonTripleClick(MouseButton button)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            var semanticEvent = new SemanticInputEvent((int)SemanticValue.SV_SelectAll);

            semanticEvent.d_payload.source = PointerSourceHelper.ConvertToPointerSource(button);

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 6
0
        public virtual bool InjectMouseWheelChange(float delta)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            var semanticEvent = new SemanticInputEvent((int)SemanticValue.SV_VerticalScroll)
            {
                d_payload = { single = delta }
            };

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 7
0
        public virtual bool InjectMouseButtonUp(MouseButton button)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            SemanticInputEvent semanticEvent = new SemanticInputEvent((int)SemanticValue.SV_CursorActivate)
            {
                d_payload = { source = PointerSourceHelper.ConvertToPointerSource(button) }
            };

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 8
0
        public virtual bool InjectMousePosition(float xPos, float yPos)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            d_pointerPosition = new Lunatics.Mathematics.Vector2(xPos, yPos);

            var semanticEvent = new SemanticInputEvent((int)SemanticValue.SV_CursorMove)
            {
                d_payload = { array = new[] { xPos, yPos } }
            };

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 9
0
        public virtual bool InjectMouseButtonClick(MouseButton button)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            var semanticEvent = new SemanticInputEvent((int)SemanticValue.SV_CursorActivate);

            if (IsControlPressed())
            {
                semanticEvent.d_value = (int)SemanticValue.SV_SelectCumulative;
            }

            semanticEvent.d_payload.source = PointerSourceHelper.ConvertToPointerSource(button);

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 10
0
        private bool handleCursorLeave(SemanticInputEvent @event)
        {
            if (GetWindowContainingCursor() == null)
            {
                return(false);
            }

            var ciea = new CursorInputEventArgs(null);

            ciea.Position  = GetWindowContainingCursor().GetUnprojectedPosition(_cursor.GetPosition());
            ciea.moveDelta = Lunatics.Mathematics.Vector2.Zero;
            ciea.Source    = CursorInputSource.None;
            ciea.scroll    = 0;
            ciea.Window    = GetWindowContainingCursor();

            GetWindowContainingCursor().OnCursorLeaves(ciea);
            ResetWindowContainingCursor();

            return(ciea.handled != 0);
        }
Exemplo n.º 11
0
        private bool handleScrollEvent(SemanticInputEvent @event)
        {
            CursorInputEventArgs ciea = new CursorInputEventArgs(null);

            ciea.Position  = _cursor.GetPosition();
            ciea.moveDelta = Lunatics.Mathematics.Vector2.Zero;
            ciea.Source    = CursorInputSource.None;
            ciea.scroll    = @event.d_payload.single;
            ciea.Window    = GetTargetWindow(ciea.Position, false);
            // make cursor position sane for this target window
            if (ciea.Window != null)
            {
                ciea.Position = ciea.Window.GetUnprojectedPosition(ciea.Position);
            }

            // if there is no target window, input can not be handled.
            if (ciea.Window == null)
            {
                return(false);
            }

            ciea.Window.OnScroll(ciea);
            return(ciea.handled != 0);
        }
Exemplo n.º 12
0
 /// <summary>
 ///  Handles the specified semantic input event and generate a navigation if
 /// that is the case (a mapping matches)
 /// </summary>
 /// <param name="event">
 /// The semantic input event
 /// </param>
 public void HandleSemanticEvent(SemanticInputEvent @event)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
        public virtual bool InjectMouseButtonDown(MouseButton button)
        {
            if (d_inputReceiver == null)
            {
                return(false);
            }

            //
            // Handling for multi-click generation
            //
            var tkr = d_mouseClickTrackers[(int)button];

            tkr.d_click_count++;

            // TODO: re-add the check for different windows?
            // if multi-click requirements are not met
            if (((d_mouseButtonMultiClickTimeout > 0) && (tkr.d_timer.Elapsed() > d_mouseButtonMultiClickTimeout)) ||
                (!tkr.d_click_area.IsPointInRect(d_pointerPosition)) ||
                (tkr.d_click_count > 3))
            {
                // reset to single down event.
                tkr.d_click_count = 1;

                // build new allowable area for multi-clicks
                tkr.d_click_area.Position = d_pointerPosition;
                tkr.d_click_area.Size     = d_mouseButtonMultiClickAbsoluteTolerance;
                tkr.d_click_area.Offset(new Lunatics.Mathematics.Vector2(
                                            -(d_mouseButtonMultiClickAbsoluteTolerance.Width / 2),
                                            -(d_mouseButtonMultiClickAbsoluteTolerance.Height / 2)));
            }

            // reset timer for this tracker.
            tkr.d_timer.Restart();

            if (d_generateMouseClickEvents)
            {
                switch (tkr.d_click_count)
                {
                case 2:
                    return(InjectMouseButtonDoubleClick(button));

                case 3:
                    return(InjectMouseButtonTripleClick(button));
                }
            }

            var value = SemanticValue.SV_CursorPressHold;

            if (IsControlPressed())
            {
                value = SemanticValue.SV_SelectCumulative;
            }
            else if (IsShiftPressed())
            {
                value = SemanticValue.SV_SelectRange;
            }

            var semanticEvent = new SemanticInputEvent((int)value);

            semanticEvent.d_payload.source = PointerSourceHelper.ConvertToPointerSource(button);

            return(d_inputReceiver.InjectInputEvent(semanticEvent));
        }
Exemplo n.º 14
0
        private bool handleRedoRequest(SemanticInputEvent @event)
        {
            var target = GetInputTargetWindow();

            return(target != null && target.PerformRedo());
        }
Exemplo n.º 15
0
        private bool handlePasteRequest(SemanticInputEvent @event)
        {
            var target = GetInputTargetWindow();

            return(target != null && target.PerformPaste(System.GetSingleton().GetClipboard()));
        }