public void HandleRightClick(Point clickPosition, Point pan) { if (Rect.Contains(clickPosition - pan)) { RightClick?.Invoke(this, new EventArgs()); } }
private void Mouse1Input() { if (Input.GetKeyDown(KeyCode.Mouse1)) { RightClick?.Invoke(); } }
private void ButtonPanel_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right && Globals.Root.User == Users.Editor) { RightClick?.Invoke(this, EventArgs.Empty); } }
void Update() { if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject(-1)) { if (LeftClick != null) { LeftClick.Invoke(this, EventArgs.Empty); } else { } } if (Input.GetMouseButtonDown(1) && !EventSystem.current.IsPointerOverGameObject(-1)) { if (RightClick != null) { RightClick.Invoke(this, EventArgs.Empty); } else { } } if (Input.GetKeyDown(KeyCode.Escape)) { CancelClick?.Invoke(this, EventArgs.Empty); } }
public void HandleRightClick(Point clickPosition, Point pan, float scale = 1) { if (Rect.Contains(new Point((clickPosition - pan) * (1 / scale)))) { RightClick?.Invoke(this, new EventArgs()); } }
public static void OnRightClick() { if (RightClick != null) { RightClick.Invoke(); } }
private void CheckRightClick() { if (RightClick != null) { double down = 0; double up = 0; Point3D highest = list[0]; Point3D lowest = list[0]; bool clicked = false; foreach (Point3D point in list) { double isLowest = CheckPoint(point, highest); double backHigh = CheckPoint(point, lowest); if (isLowest == 0) { highest = point; lowest = point; up = 0; down = 0; continue; } if (down <= MinDepth && (isLowest == 0 && backHigh == 0)) { highest = point; lowest = point; up = 0; down = 0; continue; } if (isLowest < 0 && isLowest < down) { down = isLowest; lowest = point; } if (down <= MinDepth && backHigh > 0 && backHigh > up) { up = backHigh; } if (up >= MaxDepth) { clicked = true; break; } } if (clicked) { clickWait = SingleClickWaitCount; RightClick.Invoke(); } } }
public override void Update(double dt) { PrevKeyboard = CurrentKeyboard; CurrentKeyboard = Keyboard.GetState(); PrevMouse = CurrentMouse; CurrentMouse = Mouse.GetState(); bool isOverUI = IsOverUI(); if (CurrentMouse.LeftButton == ButtonState.Pressed) { if (LeftButtonDown != null && !isOverUI) { LeftButtonDown.Invoke(new InputEventArgs(this)); } } if (CurrentMouse.RightButton == ButtonState.Pressed) { if (RightButtonDown != null && !isOverUI) { RightButtonDown.Invoke(new InputEventArgs(this)); } } if (CurrentMouse.LeftButton == ButtonState.Pressed && PrevMouse.LeftButton == ButtonState.Released) { if (LeftClick != null && !isOverUI) { LeftClick.Invoke(new InputEventArgs(this)); } } if (CurrentMouse.RightButton == ButtonState.Pressed && PrevMouse.RightButton == ButtonState.Released) { if (RightClick != null && !isOverUI) { RightClick.Invoke(new InputEventArgs(this)); } } foreach (KeyListener listener in _listeners) { if (CurrentKeyboard.IsKeyDown(listener.Primary) && (listener.Continuous || !PrevKeyboard.IsKeyDown(listener.Primary))) { listener.Trigger(listener.Primary, this); } else if (CurrentKeyboard.IsKeyDown(listener.Alternate) && (listener.Continuous || !PrevKeyboard.IsKeyDown(listener.Alternate))) { listener.Trigger(listener.Alternate, this); } } }
private void MessageSink_MouseEventReceived(MouseEvent obj) { if (obj == MouseEvent.IconLeftMouseUp) { LeftClick?.Invoke(); } else if (obj == MouseEvent.IconRightMouseUp) { RightClick?.Invoke(); } }
void RightClickButton_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { ReleaseMouseCapture(); if (this.IsMouseOver && _clicked) { if (RightClick != null) { RightClick.Invoke(this, e); } } _clicked = false; this.IsPressed = false; }
public void OnPointerDown(PointerEventData eventData) { firstMousePos = eventData.position.y; if (Input.GetMouseButtonDown(0)) { LeftClick?.Invoke(eventData); } if (Input.GetMouseButtonDown(1)) { RightClick?.Invoke(eventData); } }
private void HexChar_MouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Focus(); Click?.Invoke(this, e); } if (e.RightButton == MouseButtonState.Pressed) { RightClick?.Invoke(this, e); } }
private void OpenLinkLabel_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { this.App.CloseNotifications -= this.OnParentCloseNotifications; RightClick?.Invoke(this, e); } else if (e.Button == MouseButtons.Left && OpenClick != null) { OpenClick(sender, e); } this.Fadeout(); }
/// <summary> /// Calls OnClick when the button is clicked. /// </summary> public override void Update() { if (Root.WasMouseLeftClick && Root.IsMouseOver(Rectangle)) { Root.ConsumeLeftClick(); OnClick(this); } if (Root.WasMouseRightClick && Root.IsMouseOver(Rectangle)) { Root.ConsumeRightClick(); RightClick?.Invoke(this); } /* * if (this.IsActive && Root.WasKeyPressed(Keys.Enter)) * { * OnClick(this); * }*/ base.Update(); }
public void OnPointerClick(PointerEventData eventData) { Debug.Log(eventData.button); switch (eventData.button) { case PointerEventData.InputButton.Left: LeftClick?.Invoke(); break; case PointerEventData.InputButton.Middle: MiddleClick?.Invoke(); break; case PointerEventData.InputButton.Right: RightClick?.Invoke(); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// 启用UI。 /// </summary> public void Start( ) { PreEvent(); UIEvent(); Click += ClickEvent; RightClick += RightClickEvent; Pressed += PressedEvent; Released += ReleasedEvent; if (ModHelper.MouseInRectangle(uiRectangle)) { if (!canUseItem) { Main.LocalPlayer.mouseInterface = true; } if (Main.mouseLeft && Main.mouseLeftRelease) { Click.Invoke(); } if (Main.mouseRight && Main.mouseRightRelease) { RightClick.Invoke(); } else if (Main.mouseLeft) { Pressed.Invoke(); } else if (Main.mouseLeftRelease) { Released.Invoke(); } } Click -= ClickEvent; RightClick -= RightClickEvent; Pressed -= PressedEvent; Released -= ReleasedEvent; Draw(Main.spriteBatch); PostEvent(); }
private void OnMouseOver() { if (Input.GetMouseButtonDown(0)) { LeftClick.Invoke(); } if (Input.GetMouseButtonDown(1)) { RightClick.Invoke(); } if (Input.GetMouseButton(0)) { LeftHold.Invoke(); } if (Input.GetMouseButton(1)) { RightHold.Invoke(); } if (Input.GetMouseButtonUp(0)) { LeftRelease.Invoke(); } if (Input.GetMouseButtonUp(1)) { RightRelease.Invoke(); } }
/// <summary> /// Function called to simulate a click on the item. /// </summary> internal void PerformRightClick() { RightClick?.Invoke(this, EventArgs.Empty); }
public Button(IUiElement content) { On <HoverEvent>(_ => { IsHovered = true; Hover?.Invoke(); }); On <BlurEvent>(_ => { IsHovered = false; Blur?.Invoke(); }); On <UiLeftClickEvent>(e => { if (!IsHovered) { return; } if (!IsClicked) { ButtonDown?.Invoke(); } IsClicked = true; if (Typematic) { Click?.Invoke(); } e.Propagating = false; }); On <UiLeftReleaseEvent>(e => { if (!IsClicked) { return; } IsClicked = false; if (Typematic) { _typematicAccrual = 0; return; } if (!IsHovered) { return; } if (DoubleClick == null || !AllowDoubleClick || SuppressNextDoubleClick) // Simple single click only button { Click?.Invoke(); SuppressNextDoubleClick = false; return; } if (ClickTimerPending) // If they double-clicked... { DoubleClick?.Invoke(); ClickTimerPending = false; // Ensure the single-click behaviour doesn't happen. } else // For the first click, just start the double-click timer. { var config = Resolve <GameConfig>(); Raise(new StartTimerEvent(TimerName, config.UI.ButtonDoubleClickIntervalSeconds, this)); ClickTimerPending = true; } }); On <UiRightClickEvent>(e => { e.Propagating = false; IsRightClicked = true; }); On <UiRightReleaseEvent>(e => { if (IsRightClicked && IsHovered) { RightClick?.Invoke(); } IsRightClicked = false; }); On <TimerElapsedEvent>(e => { if (e.Id != TimerName) { return; } if (!ClickTimerPending) // They've already double-clicked { return; } Click?.Invoke(); ClickTimerPending = false; }); On <EngineUpdateEvent>(e => { if (!Typematic || !IsClicked) { return; } var oldAccrual = _typematicAccrual; _typematicAccrual += e.DeltaSeconds; var rate = 8 * (int)(2 * oldAccrual); var oldAmount = (int)(oldAccrual * rate); var newAmount = (int)(_typematicAccrual * rate); var delta = newAmount - oldAmount; for (int i = 0; i < delta; i++) { Click?.Invoke(); } }); _id = Interlocked.Increment(ref _nextId); _frame = AttachChild(new ButtonFrame(content)); }
private void btnRight_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { DismissWindow(); RightClick?.Invoke(this, e); }
private void btn_NotShow_Click(object sender, RoutedEventArgs e) { RightClick.Invoke(this, e); }
// update // - check for mouse hovering and click (select) public void Update(GameTime gameTime, KeyboardState keyboardState, Camera camera, GameState state) { // update tile? IsGlowing = false; IsPreviewingRoad = false; #region MOUSE INTERACTION LOGIC var currentMouse = Mouse.GetState(); // convert mouse screen position to world position var m_screenPosition = new Vector2(currentMouse.X, currentMouse.Y); var m_worldPosition = Vector2.Zero; camera.ToWorld(ref m_screenPosition, out m_worldPosition); // apply offset (why the f**k this is needed I absolutely do not know but I randomly f*****g figured out this formula and somehow it works so for the love of f**k - do not change this until a superior solution is TESTED and delivered m_worldPosition.X -= camera.Width / 2f; m_worldPosition.Y -= camera.Height / 2f; //m_worldPosition.X += (GraphicsDevice_.Viewport.Width * 0.25f); //m_worldPosition.Y += (GraphicsDevice_.Viewport.Height * 0.25f); // get bounds for mouse world position var mouseRectangle = new Rectangle((int)m_worldPosition.X, (int)m_worldPosition.Y, 1, 1); // check if mouse bounds intersects with tile touchbox bounds if (mouseRectangle.Intersects(TouchHitbox) && IsVisible.Equals(true)) { state.CurrentlyHoveredTile = this; //Console.WriteLine($"Hover:: Mp=>{currentMouse.Position.ToString()} :: Mwp=>{m_worldPosition.ToString()} :: Tp=>{Position.ToString()}"); //Console.WriteLine($"Hovering Over Tile: {TileIndex.ToString()}"); switch (currentMouse.LeftButton) { case ButtonState.Pressed when _previousMouseState.LeftButton == ButtonState.Pressed: if (!(state.CurrentlyPressedTile.TileIndex.Equals(TileIndex))) { Pressing?.Invoke(this, new EventArgs()); } break; case ButtonState.Pressed when _previousMouseState.LeftButton == ButtonState.Released: Pressed?.Invoke(this, new EventArgs()); break; case ButtonState.Released when _previousMouseState.LeftButton == ButtonState.Pressed: Click?.Invoke(this, new EventArgs()); break; } if (currentMouse.RightButton == ButtonState.Released && _previousMouseState.RightButton == ButtonState.Pressed) { //camera.Position = Position + new Vector2(0, 150); RightClick?.Invoke(this, new EventArgs()); } } #endregion if (Object is Residence r) { //Console.Out.WriteLine("Listing residents for tile: {0}", TileIndex.ToString()); foreach (var res in r.Residents) { //Console.Out.WriteLine("res.Name = {0}", res.Name); } } if (HasAnimatedTexture == false) { CheckForAnimatedTexture(); } // save mouse state as previous mousestate for next update call _previousMouseState = currentMouse; _gameState = state; }
public virtual void OnRightClick() { RightClick?.Invoke(this, EventArgs.Empty); }
protected void OnRightClick(EventArgs e) { RightClick?.Invoke(this, e); }
private void RightButton_Click(object sender, RoutedEventArgs e) { DismissWindow(); RightClick?.Invoke(this, e); }
public VisualInventorySlot(InventorySlotId slotId, IText amountSource, Func <IReadOnlyItemSlot> getSlot) { On <IdleClockEvent>(e => _frameNumber++); _slotId = slotId; _getSlot = getSlot; _overlay = new UiSpriteElement(Base.CoreSprite.UiBroken) { IsActive = false }; var text = new UiText(amountSource); if (!slotId.Slot.IsSpecial()) { _size = slotId.Slot.IsBodyPart() ? new Vector2(18, 18) : //16x16 surrounded by 1px borders new Vector2(16, 20); _sprite = new UiSpriteElement(SpriteId.None); _button = AttachChild(new Button(new FixedPositionStack() .Add( new LayerStack( _sprite, _overlay), 1, 1, 16, 16) //16x16 surrounded by 1px borders .Add(text, 0, 20 - 9, 16, 9)) { Padding = -1, Margin = 0, Theme = slotId.Slot.IsBodyPart() ? (ButtonFrame.ThemeFunction)ButtonTheme.Default : ButtonTheme.InventorySlot, IsPressed = !slotId.Slot.IsBodyPart() } .OnHover(() => Hover?.Invoke()) .OnBlur(() => Blur?.Invoke()) .OnClick(() => Click?.Invoke()) .OnRightClick(() => RightClick?.Invoke()) .OnDoubleClick(() => DoubleClick?.Invoke()) .OnButtonDown(() => ButtonDown?.Invoke())); } else { _sprite = new UiSpriteElement( slotId.Slot == ItemSlotId.Gold ? Base.CoreSprite.UiGold : Base.CoreSprite.UiFood); _button = AttachChild(new Button( new VerticalStack( new Spacing(31, 0), _sprite, new UiText(amountSource) ) { Greedy = false }) .OnHover(() => Hover?.Invoke()) .OnBlur(() => Blur?.Invoke()) .OnClick(() => Click?.Invoke()) .OnRightClick(() => RightClick?.Invoke()) .OnDoubleClick(() => DoubleClick?.Invoke()) .OnButtonDown(() => ButtonDown?.Invoke())); } }
/// <summary> /// Raises the <see cref="E:RightClick"/> event. /// </summary> /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param> protected virtual void OnRightClick(MouseEventArgs e) { RightClick?.Invoke(this, e); }
protected override void OnMouseDown(MouseEventArgs e) { if (doc == null) { return; } switch (mode) { case EditMode.Tile: if (e.Button == MouseButtons.Left) { if (doc != null && Mode == EditMode.Tile && Tile != null) { Point pt = e.Location; pt.X = (pt.X - AutoScrollPosition.X) / doc.TileSize; pt.Y = (pt.Y - AutoScrollPosition.Y) / doc.TileSize; if (pt.X >= 0 && pt.Y >= 0 && pt.X < doc.Size.Width && pt.Y < doc.Size.Height) { doc.SetTile(pt.X, pt.Y, Tile); } } tilePainting = true; } break; case EditMode.Entrance: if (e.Button == MouseButtons.Right) { entranceSelected = -1; } else if (e.Button == MouseButtons.Left) { if (entranceResizeIndex != -1) { entranceResizing = true; entranceSelected = entranceResizeIndex; ClickEntrance.Invoke(this, new EntranceEventArgs(entranceSelected)); UpdateObjects(); } if (entranceMoveIndex != -1) { Entrance en = doc.GetEntrance(entranceMoveIndex); entranceMoving = true; entranceMoveOffset.X = en.Rect.X - mouse.X; entranceMoveOffset.Y = en.Rect.Y - mouse.Y; entranceSelected = entranceMoveIndex; ClickEntrance.Invoke(this, new EntranceEventArgs(entranceSelected)); UpdateObjects(); } } break; case EditMode.Way: if (e.Button == MouseButtons.Right) { waySelectIndex = -1; } else if (e.Button == MouseButtons.Left) { if (entranceMoveIndex != -1) { waySelectIndex = -1; Entrance en = doc.GetEntrance(entranceMoveIndex); entranceMoving = true; entranceMoveOffset.X = en.Rect.X - mouse.X; entranceMoveOffset.Y = en.Rect.Y - mouse.Y; entranceSelected = entranceMoveIndex; ClickEntrance.Invoke(this, new EntranceEventArgs(entranceSelected)); UpdateObjects(); } if (wayHoverIndex != -1) { entranceSelected = -1; waySelectIndex = wayHoverIndex; UpdateObjects(); } if (wayPointHoverIndex != -1) { wayPointMoving = true; wayPointMoveOffset.X = doc.Ways[wayHoverIndex].Points[wayPointHoverIndex].X - mouse.X; wayPointMoveOffset.Y = doc.Ways[wayHoverIndex].Points[wayPointHoverIndex].Y - mouse.Y; wayPointMoveIndex = wayPointHoverIndex; wayMoveIndex = wayHoverIndex; } } break; case EditMode.Walkable: { Point pt = e.Location; pt.X = (pt.X - AutoScrollPosition.X) / doc.TileSize; pt.Y = (pt.Y - AutoScrollPosition.Y) / doc.TileSize; if (pt.X >= 0 && pt.Y >= 0 && pt.X < doc.Size.Width && pt.Y < doc.Size.Height) { Tile tile = doc.GetTile(pt.X, pt.Y); if (tile != null) { Point sub = e.Location; sub.X = (sub.X - AutoScrollPosition.X) / (doc.TileSize / 4); sub.Y = (sub.Y - AutoScrollPosition.Y) / (doc.TileSize / 4); sub.X -= pt.X * 4; sub.Y -= pt.Y * 4; tile.Mask[sub.X + sub.Y * 4] = (e.Button == MouseButtons.Left); TileManager.Change(tile); } } walkablePainting = true; } break; } if (e.Button == MouseButtons.Left && wayPointHoverIndex == -1) { Click.Invoke(this, new MapClickEventArgs(mouse)); } else if (e.Button == MouseButtons.Right) { RightClick.Invoke(this, new MapClickEventArgs(mouse)); } if (attachedView != null) { attachedView.UpdateTitle(); } base.OnMouseDown(e); }