Esempio n. 1
0
 internal protected virtual void TriggerOnMouseClick(Component sender, int x, int y, MouseButton button)
 {
     if (OnMouseClick != null)
     {
         OnMouseClick.Invoke(new MouseButtonEventArgs(sender, x, y, button));
     }
 }
Esempio n. 2
0
        public virtual void Update(MouseState Mouse, KeyboardState KeyBoard, GameTime gameTime, int ContainerX, int ContainerY)
        {
            ClickRect = new Rectangle(SizeBox.X + ContainerX, SizeBox.Y + ContainerY, SizeBox.Width, SizeBox.Height);
            // The active state from the last frame is now old
            lastMouseState = currentMouseState;

            // Get the mouse state relevant for this frame
            currentMouseState = Mouse;

            // Get if control containe the mouse pointer
            if (ClickRect.Contains(Mouse.Position))
            {
                if (currentMouseState.LeftButton == ButtonState.Pressed)
                {
                    MouseDown = true;
                }
                else
                {
                    MouseDown = false;
                }

                MouseOver = true;
                // Recognize a single click of the left mouse button
                if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released)
                {
                    Audio.SoundEffectEngine.PlaySoundEffects(SE);
                    OnMouseClick?.Invoke();
                }
            }
            else
            {
                MouseDown = false;
                MouseOver = false;
            }
        }
Esempio n. 3
0
        private void OpenGlControl_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            var control       = (GlControl)sender;
            var relativePoint = control.PointToClient(e.Location);

            OnMouseClick?.Invoke(sender, new Vector2(e.X, e.Y));
        }
 public NodeDataInfoPanel()
 {
     Active = false;
     OnMouseClick.Add(UseEvent);
     OnRightClick.Add(UseEvent);
     OnMouseDown.Add(UseEvent);
 }
Esempio n. 5
0
    private void Update()
    {
        if (Input.GetMouseButton(0))
        {
            OnMouseClick?.Invoke(CursorToMapPosition());
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            StartCoroutine(FindAndDrawPath());
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            StartCoroutine(FindAndDrawPathWithoutRegions());
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            StartCoroutine(FindAndDrawDefaultPath());
        }

        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            StartCoroutine(FindAndDrawRCostPath());
        }
    }
Esempio n. 6
0
 public void pointCheck(int pointX, int pointY)
 {
     if (pointX >= x && pointX <= x + (int)bitmapBrush.Bitmap.Size.Width)
     {
         if (pointY >= y && pointY <= y + (int)bitmapBrush.Bitmap.Size.Height)
         {
             OnMouseClick?.Invoke(null, null);
         }
     }
 }
Esempio n. 7
0
        public override void InitFinish()
        {
            base.InitFinish();
            FilterField.OnContentChange = () => { OnContentChange(); };
            OnMouseClick.Add((c, e) => e.Use());

            FilterField.Editable      = true;
            FilterField.Content       = "";
            FilterField.Color         = Color.gray;
            FilterField.TextFontStyle = FontStyle.BoldAndItalic;
        }
Esempio n. 8
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         isMouseHeld = true;
     }
     else if (isMouseHeld && Input.GetMouseButtonUp(0))
     {
         isMouseHeld = false;
         OnMouseClick?.Invoke();
     }
 }
Esempio n. 9
0
 protected override bool OnMouseDown(MouseDownEvent e)
 {
     if (e.Button == MouseButton.Left)
     {
         if (EditorMode2)
         {
             ClickAction?.Invoke();
             OnMouseClick?.Invoke();
         }
     }
     return(base.OnMouseDown(e));
 }
 public EditorButton()
 {
     _localSize = new Rect(Vector2.zero, Size);
     OnSizeChange.Add(OnRectChange);
     _bg     = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Editor/Resources/NodeSelectBtn.png");
     _hover  = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Editor/Resources/NodeSelectBtnHover.png");
     _onDown = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Editor/Resources/NodeSelectBtnDown.png");
     OnMouseClick.Add((c, e) =>
     {
         e.Use();
     });
     InitStyle();
 }
Esempio n. 11
0
        private void Hook_MouseUp(object sender, MouseEventArgs e)
        {
            Task.Run(async() =>
            {
                if (!Enabled || !configuration.CloseOverlayWithMouse)
                {
                    return;
                }

                if (OnMouseClick != null)
                {
                    await OnMouseClick.Invoke(e.X, e.Y);
                }
            });
        }
 public virtual void MouseClick(Vector2 mouseGlobalPosition)
 {
     if (ContainsMouse(mouseGlobalPosition))
     {
         OnMouseClick?.Invoke(this, Args);
         if (!ActionOnRelease)
         {
             Action?.Invoke(this, Args);
         }
     }
     else
     {
         OnMouseClickOutside?.Invoke(this, Args);
     }
 }
Esempio n. 13
0
    private BuildButton GenerateNewBuildButton(BuildInfo m_BuildInfo)
    {
        BuildButton newBuildButton = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.BuildButton].AllocateGameObject <BuildButton>(AllMyBuildsContainer);

        newBuildButton.Initialize(m_BuildInfo);

        CreateNewBuildButton.transform.parent.SetAsLastSibling();

        OnMouseClick bbc = newBuildButton.Button.GetComponent <OnMouseClick>();

        bbc.ResetListeners();
        bbc.LeftClick.AddListener(delegate { OnSwitchEditBuild(newBuildButton); });
        bbc.RightClick.AddListener(delegate { OnRightClickBuildButtonToRename(newBuildButton.BuildInfo); });
        bbc.LeftDoubleClick.AddListener(delegate { OnBuildButtonDoubleClickToSelect(newBuildButton); });
        return(newBuildButton);
    }
Esempio n. 14
0
    private void Update()
    {
        if (!Input.GetMouseButtonUp(0))
        {
            return;
        }

        RectTransformUtility.ScreenPointToLocalPointInRectangle(_rectTransform, Input.mousePosition,
                                                                GetComponentInParent <Canvas>().worldCamera, out var localPoint);
        var normalizedPoint = Rect.PointToNormalized(_rectTransform.rect, localPoint);

        OnMouseClick?.Invoke(normalizedPoint);

        _targetHighlight.SetTarget(normalizedPoint, _rectTransform.rect);
        // Debug.Log(normalizedPoint);
    }
Esempio n. 15
0
    private void Update()
    {
        GetMousePos();

        // On right click
        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (hit.collider != null)
            {
                // If already configuring node
                if (_configuringNodeRotation)
                {
                    // Rotate the node to face new clicked target
                    var clickedElement = hit.collider.GetComponent <RuneElement>();
                    _lookAtNode = clickedElement.transform.parent.GetComponent <RuneNode>();
                    _configuringNode.RotateTowards(_lookAtNode);
                    _configuringNodeRotation = false;
                    _lookAtNode      = null;
                    _configuringNode = null;
                }
                else
                {
                    // Check if on an injection node
                    var injectionElement = hit.collider.GetComponent <InjectionElement>();
                    if (injectionElement != null)
                    {
                        _configuringNodeRotation = true;
                        _configuringNode         = injectionElement.transform.parent.GetComponent <RuneNode>();
                        Debug.Log("Configuring injection node");
                    }
                }
            }
        }

        // Call events
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            OnMouseClick?.Invoke();
        }
        else
        {
            OnMouseNormal?.Invoke();
        }
    }
Esempio n. 16
0
    void OnMouseClick(OnMouseClick e)
    {
        Cell lCell = null;

        if (e.clickObject)
        {
            lCell = e.clickObject.GetComponent <Cell>();
        }

        //Did we click on an other cell or empty?
        if (lCell != null)
        {
            OnCellClicked(lCell);
        }
        else
        {
            Deselection();
        }
    }
Esempio n. 17
0
    private void Update()
    {
        if (isSettlementInPrePlace)
        {
            settlement.transform.localPosition = Vector3.Lerp(endMarker, startMarker, Mathf.PingPong(Time.time, 1.0f));
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit) && hit.transform == transform)
            {
                Debug.Log("Settlement click");
                OnMouseClick?.Invoke(this, transform);
            }
        }
    }
Esempio n. 18
0
    private void MouseUp(int buttonId, Vector3 mousePosition)
    {
        if (!canInputBeMade)
        {
            return;
        }

        if (!BuilderInWorldUtils.IsPointerOverUIElement() && !BuilderInWorldUtils.IsPointerOverMaskElement(layerToStopClick))
        {
            OnMouseUp?.Invoke(buttonId, mousePosition);
            if (Vector3.Distance(mousePosition, lastMousePosition) >= movementClickThreshold)
            {
                return;
            }
            if (Time.unscaledTime >= lastTimeMouseDown + msClickThreshold / 1000)
            {
                return;
            }
            OnMouseClick?.Invoke(buttonId, mousePosition);
        }
    }
    private void MouseUp(int buttonId, Vector3 mousePosition)
    {
        if (!isEditModeActive)
        {
            return;
        }

        if (currentClickIsOnUi)
        {
            OnMouseClickOnUI?.Invoke(buttonId, mousePosition);
            currentClickIsOnUi = false;
            return;
        }

        if (!canInputBeMade)
        {
            return;
        }

        if (!BIWUtils.IsPointerOverUIElement())
        {
            OnMouseUp?.Invoke(buttonId, mousePosition);
            if (Vector3.Distance(mousePosition, lastMousePosition) >= MOVEMENT_CLICK_THRESHOLD)
            {
                return;
            }
            if (Time.unscaledTime >= lastTimeMouseDown + MS_CLICK_THRESHOLD / 1000)
            {
                return;
            }
            OnMouseClick?.Invoke(buttonId, mousePosition);
        }
        else
        {
            OnMouseUpOnUI?.Invoke(buttonId, mousePosition);
        }
    }
Esempio n. 20
0
    public void NextState()
    {
        Debug.Log("next state");

        switch (state)
        {
        case GameState.BEFOREROLLDICE:
            break;

        case GameState.AFTERDICE:
            break;

        case GameState.ENDOFGAME:
            break;

        case GameState.WAIT:
            OnWaitClick?.Invoke(this, EventArgs.Empty);
            break;

        case GameState.NORMAL:
            OnMouseClick?.Invoke(this, transform);
            break;
        }
    }
Esempio n. 21
0
        // Unity Events ------------------------------------------------------------------------------------------------
        // Pointer

        public void OnPointerClick(PointerEventData eventData)
        {
            // starts build phase
            OnMouseClick?.Invoke(Building);
        }
Esempio n. 22
0
        public TreeNodeCanvas()
        {
            OnMouseClick.Add(MouseClick);
            OnMouseDown.Add((k, e) =>
            {
                if (e.Event.button == 2 || e.Event.button == 1)
                {
                    _down = true;
                }
            });

            OnMouseUp.Add((k, e) =>
            {
                if (e.Event.button == 2 || e.Event.button == 1)
                {
                    _down = false;
                }
            });
            OnKeyDown.Add((k, e) =>
            {
                switch (e.Event.keyCode)
                {
                case KeyCode.Delete:
                    BeTreeNode node = _curSelected;
                    if (_curSelected == null)
                    {
                        return;
                    }
                    DeleteItem(node);
                    break;

                case KeyCode.Escape:
                    if (_curSelected != null)
                    {
                        SelectedNode(null);
                        break;
                    }
                    if (EditorUtility.DisplayDialog("Close window", "You will lose all the unsafed data.", "Confirm", "Cancel"))
                    {
                        (Root as EditorWindow).Close();
                    }
                    break;

                case KeyCode.S:
                    if (e.Event.control)
                    {
                        if (e.Event.alt)
                        {
                            OnSaveToJson?.Invoke();
                        }
                        else
                        {
                            OnSave?.Invoke();
                        }
                    }
                    break;

                case KeyCode.O:
                    if (e.Event.control && e.Event.alt)
                    {
                        OpenPanel();
                    }
                    break;

                case KeyCode.N:
                    if (e.Event.control && e.Event.alt)
                    {
                        if (!e.Event.shift)
                        {
                            CreatePanel("prefab");
                        }
                        else
                        {
                            CreatePanel("txt");
                        }
                    }
                    break;
                }
            });
        }
Esempio n. 23
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     // todo - do we need to check for null?
     OnMouseClick?.Invoke(this, e);
 }
        /// <summary>
        /// Update cursor and keyboard events
        /// </summary>
        private void UpdateCursorAndKeyboardEvents()
        {
            if (!Visible)
            {
                return;
            }

            MouseEvent    mouseState = MouseHandler.GetState();
            KeyboardState kbState    = KeyboardHandler.GetState();
            var           mouseSize  = new Vector2(5);

            var mouseRect = new Rectangle((int)mouseState.X, (int)mouseState.Y, (int)mouseSize.X, (int)mouseSize.Y);

            var thisRect = new Rectangle((int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y);

            //First check position
            if (mouseRect.Intersects(thisRect))
            {
                //Second, check buttons

                //Left
                if (LastMouseCheck.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed)
                {
                    OnMouseDown?.Invoke(this, mouseState.Position, MouseButtons.Left);
                }

                if (LastMouseCheck.LeftButton == ButtonState.Pressed && mouseState.LeftButton == ButtonState.Released)
                {
                    OnMouseUp?.Invoke(this, mouseState.Position, MouseButtons.Left);
                    OnMouseClick?.Invoke(this, mouseState.Position, MouseButtons.Left);
                }

                //Right
                if (LastMouseCheck.RightButton == ButtonState.Released && mouseState.RightButton == ButtonState.Pressed)
                {
                    OnMouseDown?.Invoke(this, mouseState.Position, MouseButtons.Right);
                }

                if (LastMouseCheck.RightButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Released)
                {
                    OnMouseUp?.Invoke(this, mouseState.Position, MouseButtons.Right);
                    OnMouseClick?.Invoke(this, mouseState.Position, MouseButtons.Right);
                }

                //Middle
                if (LastMouseCheck.MiddleButton == ButtonState.Released && mouseState.MiddleButton == ButtonState.Pressed)
                {
                    OnMouseDown?.Invoke(this, mouseState.Position, MouseButtons.Middle);
                }

                if (LastMouseCheck.MiddleButton == ButtonState.Pressed && mouseState.MiddleButton == ButtonState.Released)
                {
                    OnMouseUp?.Invoke(this, mouseState.Position, MouseButtons.Middle);
                    OnMouseClick?.Invoke(this, mouseState.Position, MouseButtons.Middle);
                }

                //Check move

                if (LastMouseCheck.Position != mouseState.Position)
                {
                    OnMouseMove?.Invoke(this, mouseState.Position, MouseButtons.None);
                }

                //Hook Keyboard

                if (kbState.GetPressedKeys().Count() > 0 && LastKeyboardState.GetPressedKeys().Count() > 0)
                {
                    //check pressed keys
                    List <Keys> pressedKeys = kbState.GetPressedKeys().Except(LastKeyboardState.GetPressedKeys()).ToList();

                    foreach (Keys p in pressedKeys)
                    {
                        OnKeyPress?.Invoke(this, p, kbState);
                    }

                    //check released keys
                    List <Keys> releasedKeys = LastKeyboardState.GetPressedKeys().Except(kbState.GetPressedKeys()).ToList();

                    foreach (Keys r in releasedKeys)
                    {
                        OnKeyUp?.Invoke(this, r, kbState);
                        OnKeyPress?.Invoke(this, r, kbState);
                    }
                }
            }
            else
            {
                // Leave == Release

                //Left
            }

            LastMouseCheck    = mouseState;
            LastKeyboardState = kbState;
        }
Esempio n. 25
0
 public void InvokeMouseClick(MouseButtonEventArgs e)
 {
     OnMouseClick?.Invoke(e);
 }
Esempio n. 26
0
 private void OnMouseUpAsButton()
 {
     OnMouseClick?.Invoke();
 }
Esempio n. 27
0
File: Mouse.cs Progetto: nchos88/SOA
        private void HookMouseCallback(HookData hookData)
        {
            MouseEventInformation info = MouseEventInformation.Get(hookData);

            int          mx     = info.X;
            int          my     = info.Y;
            MouseButtons button = info.Button;

            // 마우스 다운
            if (info.IsMouseDown)
            {
                if (IsDoubleClick(info))
                {
                    info = info.ToDobuleClickMouseEventInformation();
                }

                OnMouseDown?.Invoke(mx, my, button);

                if (info.Clicks == 2)
                {
                    m_DoubleButton |= info.Button;
                }

                if (info.Clicks == 1)
                {
                    m_SingleButton |= button;
                }
            }

            // 마우스 업
            if (info.IsMouseUp)
            {
                OnMouseUp?.Invoke(mx, my, button);

                // 마우스 클릭
                if ((m_SingleButton & button) != MouseButtons.None)
                {
                    OnMouseClick?.Invoke(mx, my, button);
                    m_SingleButton &= ~button;
                }

                // 마우스 더블 클릭
                if ((m_DoubleButton & button) != MouseButtons.None)
                {
                    OnMouseDoubleClick?.Invoke(mx, my, button);
                    m_DoubleButton &= ~button;
                }

                if (info.Clicks == 2)
                {
                    m_PreviousClickedButton = MouseButtons.None;
                    m_PreviousClickedTime   = 0;
                    m_PreviousClickedX      = m_DefaultPositionXY;
                    m_PreviousClickedY      = m_DefaultPositionXY;
                }

                if (info.Clicks == 1)
                {
                    m_PreviousClickedButton = info.Button;
                    m_PreviousClickedTime   = info.Timestamp;
                    m_PreviousClickedX      = mx;
                    m_PreviousClickedY      = my;
                }
            }

            // 마우스 스크롤
            if (info.IsMouseWheelScrolled)
            {
                OnMouseWheel?.Invoke(mx, my, button, info.Delta > 0 ? 1 : -1);
            }

            // 마우스 이동
            if (IsMoved(mx, my))
            {
                m_PreviousX = mx;
                m_PreviousY = my;

                OnMouseMove?.Invoke(mx, my, button);
            }

            // 마우스 드래그
            if ((m_SingleButton & MouseButtons.Left) != MouseButtons.None)
            {
                if (m_DragStartPositionX == m_DefaultPositionXY && m_DragStartPositionY == m_DefaultPositionXY)
                {
                    m_DragStartPositionX = mx;
                    m_DragStartPositionY = my;
                }

                // 마우스 드래그 스타트
                if (m_dragMode == false)
                {
                    bool isXDragging = Math.Abs(mx - m_DragStartPositionX) > m_SystemDragX;
                    bool isYDragging = Math.Abs(my - m_DragStartPositionY) > m_SystemDragY;

                    m_dragMode = isXDragging || isYDragging;

                    if (m_dragMode == true)
                    {
                        OnMouseDragStart?.Invoke(mx, my, button);
                    }
                }
            }
            else
            {
                m_DragStartPositionX = m_DefaultPositionXY;
                m_DragStartPositionY = m_DefaultPositionXY;

                // 마우스 드래그 엔드
                if (m_dragMode == true)
                {
                    OnMouseDragEnd?.Invoke(mx, my, button);

                    m_dragMode = false;
                }
            }
        }
Esempio n. 28
0
 public Button(string strs, OnMouseClick del = null)
 {
     str     = strs;
     OnClick = del;
 }
Esempio n. 29
0
 public Label(string strs, OnMouseClick del = null)
 {
     str     = strs;
     OnClick = del;
 }
Esempio n. 30
0
        private void Update()
        {
            if (CheckKey(KeyCode.W))
            {
                OnWPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.W);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.A))
            {
                OnAPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.A);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.S))
            {
                OnSPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.S);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.D))
            {
                OnDPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.D);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.Space))
            {
                OnSpacePressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.Space);
                OnKeyPressed?.Invoke(this, args);
            }

            RunKey(KeyCode.G);
            RunKey(KeyCode.H);
            RunKey(KeyCode.Q);
            RunKey(KeyCode.Escape);

            var scrollDelta = Input.GetAxis("Mouse ScrollWheel");

            if (scrollDelta != 0.0F)
            {
                ScrollEventArgs args;
                if (scrollDelta > 0.0F)
                {
                    args = new ScrollEventArgs(true);
                    OnScrollUp?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    args = new ScrollEventArgs(false);
                    OnScrollDown?.Invoke(this, EventArgs.Empty);
                }
                OnScroll?.Invoke(this, args);
            }

            if (CheckMouseSingle(MouseButton.LEFT))
            {
                ClickEventArgs args = new ClickEventArgs(MouseButton.LEFT, Input.mousePosition);
                OnMouseClick?.Invoke(this, args);
                OnLeftMouseClick?.Invoke(this, args);
            }
            if (CheckMouseSingle(MouseButton.RIGHT))
            {
                ClickEventArgs args = new ClickEventArgs(MouseButton.RIGHT, Input.mousePosition);
                OnMouseClick?.Invoke(this, args);
                OnRightMouseClick?.Invoke(this, args);
            }
        }