public override void resetProperty() { base.resetProperty(); // 重置所有成员变量 mObjectID = -1; mPhysicsAcceleration = Vector3.zero; mLastPhysicsSpeed = Vector3.zero; mPhysicsSpeed = Vector3.zero; mLastPhysicsPosition = Vector3.zero; mCurFramePosition = Vector3.zero; mLastPosition = Vector3.zero; mMouseDownPosition = Vector3.zero; mLastSpeed = Vector3.zero; mMoveSpeed = Vector3.zero; mObject = null; mTransform = null; mAudioSource = null; mOnMouseEnter = null; mOnMouseLeave = null; mOnMouseDown = null; mOnMouseUp = null; mOnMouseMove = null; mClickCallback = null; mHoverCallback = null; mPressCallback = null; mMovedDuringFrame = false; mHasLastPosition = false; mDestroyObject = true; mDestroied = false; mMouseHovered = false; mHandleInput = true; mPassRay = false; }
public static void ProcessMouseEvent(SDL_Event ev) { switch (ev.type) { case SDL_EventType.SDL_MOUSEBUTTONDOWN: SetMouseButtonState(ev.button.button, true); if (OnMouseDown != null) { var button = TranslatePlatformMouseButton(ev.button.button); OnMouseDown.Invoke(button); } break; case SDL_EventType.SDL_MOUSEBUTTONUP: SetMouseButtonState(ev.button.button, false); if (OnMouseUp != null) { var button = TranslatePlatformMouseButton(ev.button.button); OnMouseUp.Invoke(button); } break; case SDL_EventType.SDL_MOUSEMOTION: OnMouseMove?.Invoke(); break; } }
private async Task OnItemMouseDownAsync(int index) { if (KeyboardInteractions && !AppliedDisabled) { await OnMouseDown.InvokeAsync(index); } }
IntPtr HookProcFunction(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode == 0) { MSLLHOOKSTRUCT mhs = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); var inwindow = Owner.MouseInWindow(mhs.pt.X, mhs.pt.Y); switch ((WM)wParam.ToInt32()) { case WM.MOUSEMOVE: if (inwindow) { OnMouseMove?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, Owner.GetMouseButtonConsole()); } OnGlobalMouseMove?.Invoke(mhs.pt.X, mhs.pt.Y, Owner.GetMouseButtonScreen()); break; case WM.LBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Left); break; case WM.MBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Center); break; case WM.RBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Right); break; case WM.XBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.XBUTTON1 | MButton.XBUTTON2); break; case WM.LBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Left); break; case WM.MBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Center); break; case WM.RBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Right); break; case WM.XBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.XBUTTON1 | MButton.XBUTTON2); break; case WM.MOUSEWHEEL: OnMouseWheel?.Invoke(GetWheelStateByData(mhs.mouseData), mhs.mouseData, mhs.pt.X, mhs.pt.Y, Owner.GetMouseButtonScreen()); break; default: break; } } return(WinApi.CallNextHookEx(hHook, nCode, wParam, lParam)); }
// Update Method public override void Update(GameTime gameTime) { previousMouse = currentMouse; // Current and previous state currentMouse = Mouse.GetState(); // functions to recieve only one mouse click at a time Rectangle mouseRectangle = new Rectangle(currentMouse.X, currentMouse.Y, 1, 1); // Rectangle of the mouse isHovering = false; if (mouseRectangle.Intersects(Rectangle)) { isHovering = true; if (currentMouse.LeftButton == ButtonState.Pressed) // Conditions for the mouse being down { OnMouseDown?.Invoke(this, new EventArgs()); } if (currentMouse.LeftButton == ButtonState.Released && previousMouse.LeftButton == ButtonState.Pressed) // Conditions for the mouse being clicked { Click?.Invoke(this, new EventArgs()); } } if (currentMouse.LeftButton == ButtonState.Released) // Conditions for the mouse being released { OnMouseUp?.Invoke(this, new EventArgs()); } }
public BeTreeNode() { OnMouseDown.Add((k, e) => { e.Use(); }); }
private void Poll() { while (true) { VREvent_t evt = new VREvent_t(); var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t)); if (!OpenVR.Overlay.PollNextOverlayEvent(overlayHandle, ref evt, size)) { Thread.Sleep(PollingRate); continue; } ; switch ((EVREventType)evt.eventType) { case EVREventType.VREvent_MouseMove: OnMouseMove?.Invoke(this, evt); break; case EVREventType.VREvent_MouseButtonDown: OnMouseDown?.Invoke(this, evt); break; case EVREventType.VREvent_MouseButtonUp: OnMouseUp?.Invoke(this, evt); break; } } }
public void MouseDown(int X, int Y) { isMouseDown = true; OnMouseDown?.Invoke(this, new ViewportMouseDownEventArgs(Vector3.Zero)); previousMouseDragPosition = new Vector2(X, Y); }
private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) { if ((int)wParam == WM_MOUSEMOVE) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseMove?.Invoke(e)); } else if ((int)wParam == WM_LBUTTONDOWN || (int)wParam == WM_RBUTTONDOWN) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseDown?.Invoke(e)); } else if ((int)wParam == WM_LBUTTONUP || (int)wParam == WM_RBUTTONUP) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseUp?.Invoke(e)); } return(CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)); }
internal void InvokeMouseDown(float mouseX, float mouseY) { if (Enabled) { OnMouseDown?.Invoke(this, mouseX - Transform.Position.X, mouseY - Transform.Position.Y); } }
public Window(WindowConfig config) { _config = config; var opts = WindowOptions.DefaultVulkan; opts.WindowBorder = WindowBorder.Resizable; opts.Size = new Silk.NET.Maths.Vector2D <int>((int)config.Width, (int)config.Height); opts.Title = config.Title; opts.WindowState = config.Fullscreen ? WindowState.Fullscreen : WindowState.Normal; _window = Silk.NET.Windowing.Window.Create(opts); _window.Render += (time) => DrawFrame?.Invoke(time); _window.Initialize(); _input = _window.CreateInput(); var primaryKeyboard = _input.Keyboards.FirstOrDefault(); if (primaryKeyboard != null) { primaryKeyboard.KeyDown += (keyboard, key, code) => OnKeyDown?.Invoke(key); primaryKeyboard.KeyUp += (keyboard, key, code) => OnKeyUp?.Invoke(key); } for (int i = 0; i < _input.Mice.Count; i++) { _input.Mice[i].Cursor.CursorMode = config.CursorDisabled ? CursorMode.Disabled : CursorMode.Normal; _input.Mice[i].MouseMove += (mouse, pos) => OnCursorPosition?.Invoke(pos.X, pos.Y); _input.Mice[i].Scroll += (mouse, wheel) => OnScroll?.Invoke(wheel.X, wheel.Y); _input.Mice[i].MouseDown += (mouse, button) => OnMouseDown?.Invoke(button); _input.Mice[i].MouseUp += (mouse, button) => OnMouseUp?.Invoke(button); } }
public static void Initialize(ECSWorld world) { if (initialized) { return; } if (world == null) { throw new ArgumentNullException(nameof(world), "The ECSWorld provided can not be null."); } if (!world.IsMainWorld) { throw new ArgumentException("The ECSWorld of the window needs to be the mainWorld", nameof(world)); } WindowInstance = Process.GetCurrentProcess().SafeHandle.DangerousGetHandle(); window = new Sdl2Window("ECS", 50, 50, 1280, 720, SDL_WindowFlags.Resizable, threadedProcessing: false); window.X = 50; window.Y = 50; window.Visible = true; window.MouseWheel += (x) => OnMouseWheel?.Invoke(x); window.MouseMove += (x) => OnMouseMove?.Invoke(x); window.MouseDown += (x) => OnMouseDown?.Invoke(x); window.KeyDown += (x) => OnKeyDown?.Invoke(x); window.Closed += () => OnWindowClose?.Invoke(); window.Resized += () => OnWindowResize?.Invoke(window.Width, window.Height); world.EarlyUpdate += PumpEvents; initialized = true; GraphicsContext.Initialize(world); }
public NodeDataInfoPanel() { Active = false; OnMouseClick.Add(UseEvent); OnRightClick.Add(UseEvent); OnMouseDown.Add(UseEvent); }
static public void InvokeOnMouseDown(OpenTK.Input.MouseButtonEventArgs e) { if (OnMouseDown != null) { OnMouseDown.Invoke(null, e); } }
public void MouseDown(int screenX, int screenY, MouseButton button) { mouseX = screenX; mouseY = screenY; mouseButtons |= button; OnMouseDown?.Invoke(this, CreateMouseEventArgs(screenX, screenY, button)); }
public Button(int x, int y, int width, int height) { X = x; Y = y; Width = width; Height = height; MouseEvent = null; }
/// <summary> /// Необходимо вызывать при нажатии мыши /// </summary> public void MouseDown(MouseEventArgs e) { //var temp = Bpoint.DeApply(e.Location); if (_rectangle.Contains(e.Location)) { _drag = true; OnMouseDown?.Invoke(e.Location); } }
public virtual void MouseLeftDown(UIMouseEvent e) { //Main.NewText("按下"); MouseDownedLeft = true; OnMouseDown?.Invoke(e, this); if (PropagationRule.HasFlag(PropagationFlags.MouseLeftDown)) { Parent?.MouseLeftDown(e); } }
public override bool MouseDown(ScreenEventArgs args) { OnMouseDown?.Invoke(this, args); if (args.Handled) { return(true); } Destroy(); return(true); }
protected void Init() { AddToClassList(USS_CLASS_NAME); m_TextElement = new TextElement { name = "text", text = m_Text, pickingMode = PickingMode.Ignore }; m_TextElement.AddToClassList(USS_CLASS_NAME_TEXT); hierarchy.Add(m_TextElement); this.AddManipulator(new Clickable(() => OnMouseDown?.Invoke(this))); }
public AnnotationHelper( OnAnnotationChanged onAnnotationChangedCallback = null, OnPageChanged onPageChangedCallback = null, OnMouseDown onMouseDownCallback = null, OnMouseUp onMouseUpCallback = null) { OnAnnotationChangedCallback = onAnnotationChangedCallback ?? (async(W3CWebAnnotationModel[] annotations) => { }); OnPageChangedCallback = onPageChangedCallback ?? (async(int newPage) => { }); OnMouseDownCallback = onMouseDownCallback ?? (async(double viewportX, double viewportY) => { }); OnMouseUpCallback = onMouseUpCallback ?? (async(double viewportX, double viewportY) => { }); }
private void OnMouse(object sender, ButtonValueChangedArgs bvca) { if (bvca.Pressed) { OnMouseDown?.Invoke(this); } else { OnMouseUp?.Invoke(this); } }
internal void CallMouseDown() { IsMousePressed = true; OnMouseDown?.Invoke(); OnAnyMouseDown?.Invoke(); if (OwnerLoopEngine != null) { calledDragStart = false; mouseDownPos = MouseInput.ScreenPos; OwnerLoopEngine.AddLoopAction(OnMouseDragging, GLoopCycle.EveryFrame, GWhen.MouseUpRemove); } }
void MarkMouseButtonAsPressed(MSLLHOOKSTRUCT hookStruct, MouseEventArgs.Buttons button, bool pressed) { if (pressed && !_currentlyPressed.Contains((int)button)) { _currentlyPressed.Add((int)button); OnMouseDown?.Invoke(this, new MouseEventArgs(button, hookStruct.pt.x, hookStruct.pt.y)); } else if (!pressed && _currentlyPressed.Contains((int)button)) { _currentlyPressed.Remove((int)button); OnMouseUp?.Invoke(this, new MouseEventArgs(button, hookStruct.pt.x, hookStruct.pt.y)); } }
public virtual void MouseDown(MouseEventArgs e) { OnMouseDown.SafeInvoke(this, TranslateMouseEventArgs(e)); long diff = Environment.TickCount - m_tick; //250 millis if (diff < 250) { DoubleClick(e); m_tick = Environment.TickCount; } }
private void DetectMouseButtons() { if (State.LeftButton == ButtonState.Pressed && !_mouseWasDown) { OnMouseDown?.Invoke(this, GetMouseEventArgs()); _mouseWasDown = true; } else if (State.LeftButton == ButtonState.Released && _mouseWasDown) { OnMouseReleased?.Invoke(this, GetMouseEventArgs()); _mouseWasDown = false; } }
public void ListenForCommands() { try { var bytes = new byte[100]; Stream.Read(bytes, 0, bytes.Length); var package = Encoding.UTF8.GetString(bytes); var data = package.Split('|'); var type = (CommandMessageType)int.Parse(data[0]); Console.WriteLine(type); switch (type) { case CommandMessageType.MouseDown: OnMouseDown?.Invoke(new MouseEventDetails { MouseButton = data[1], X = int.Parse(data[2]), Y = int.Parse(data[3]) }); break; case CommandMessageType.MouseUp: OnMouseUp?.Invoke(new MouseEventDetails { MouseButton = data[1] }); break; case CommandMessageType.MouseDrag: OnMouseUp?.Invoke(new MouseEventDetails { MouseButton = data[1], X = int.Parse(data[2]), Y = int.Parse(data[3]) }); break; } } catch { } Task.Run(() => ListenForCommands()); }
private void MouseDown(int buttonId, Vector3 mousePosition) { lastTimeMouseDown = Time.unscaledTime; lastMousePosition = mousePosition; if (!canInputBeMade) { return; } if (!BuilderInWorldUtils.IsPointerOverUIElement() && !BuilderInWorldUtils.IsPointerOverMaskElement(layerToStopClick)) { OnMouseDown?.Invoke(buttonId, mousePosition); } }
protected void Init() { AddToClassList(USS_CLASS_NAME); AddToClassList("worldStateItem"); AddToClassList("rounded"); m_WorldStateField = new TextField("World State") { value = m_UtilityDescription.WorldStateName }; m_WorldStateField.tooltip = "The identifier of the world state. The corresponding world state value should be castable to float."; m_WorldStateField.maxLength = 30; hierarchy.Add(m_WorldStateField); m_OperatorSelectorField = new UtilityOperatorSelectorField("Operator") { value = m_UtilityDescription.UtilityOperator }; m_OperatorSelectorField.tooltip = "Defines how the resulting value will be applied to the base utility value. All curves will be applied in order of appearance."; hierarchy.Add(m_OperatorSelectorField); m_CurveField = new CurveField("Curve") { value = m_UtilityDescription.UtilityCurve }; m_CurveField.tooltip = "The curve that will be evaluated based on the world state. world state will be interpreted as a float."; hierarchy.Add(m_CurveField); m_CurveMultiplierField = new FloatField("Curve Multiplier") { value = m_UtilityDescription.CurveMultiplier }; m_CurveMultiplierField.tooltip = "The evaluated curve value will be multiplied with this number before it is applied to the base utility value."; hierarchy.Add(m_CurveMultiplierField); m_WorldStateField.RegisterValueChangedCallback(WorldStateNameChanged); m_OperatorSelectorField.RegisterValueChangedCallback(UtilityOperatorChanged); m_CurveField.RegisterValueChangedCallback(CurveChanged); m_CurveMultiplierField.RegisterValueChangedCallback(CurveMultiplierChanged); this.AddManipulator(new Clickable(() => OnMouseDown?.Invoke(this))); this.AddManipulator(new ContextualMenuManipulator(_menubuilder => { _menubuilder.menu.AppendAction("Delete", _dropDownMenuAction => OnDelete?.Invoke(this), DropdownMenuAction.Status.Normal); _menubuilder.menu.AppendAction("Duplicate", _dropDownMenuAction => OnDuplicate?.Invoke(this), DropdownMenuAction.Status.Normal); })); }
private static void InputEventHandler(InputEventArgs e) { switch (e.Type) { case InputEventType.KeyUp: OnKeyUp.Invoke(e); break; case InputEventType.KeyDown: OnKeyDown.Invoke(e); break; case InputEventType.MouseUp: OnMouseUp.Invoke(e); break; case InputEventType.MouseDown: OnMouseDown.Invoke(e); break; case InputEventType.MouseMove: OnMouseMove.Invoke(e); break; } }
public Button(string buttonText, SpriteFont font, Color mainColor, Color mouseoverColor, Texture2D mainBackground, Texture2D mouseoverBackground, float x, float y, bool centered, OnMouseDown MouseEvent) { this.buttonText = buttonText; this.font = font; this.mainColor = mainColor; this.mouseoverColor = mouseoverColor; this.mainBackground = mainBackground; this.mouseoverBackground = mouseoverBackground; // dynamically discover the width and height of the button stringsize = font.MeasureString(buttonText); // width is the max of the string or either of the background (if they were selected) width = 0; width = Math.Max(width, stringsize.X); width = Math.Max(width, (mainBackground != null ? mainBackground.Width : 0)); width = Math.Max(width, (mouseoverBackground != null ? mouseoverBackground.Width : 0)); // height is the max of the string or either of the background (if they were selected) height = 0; height = Math.Max(height, stringsize.Y); height = Math.Max(height, (mainBackground != null ? mainBackground.Height : 0)); height = Math.Max(height, (mouseoverBackground != null ? mouseoverBackground.Height : 0)); // If the button is centered, then the x,y pair points to the center of the button, otherwise it points to the top-left of the button this.centered = centered; if (centered) { this.x = x - (stringsize.X/2); this.y = y - (stringsize.Y/2); } else { this.x = x; this.y = y; } // Mouse Event Delegate this.MouseEvent = MouseEvent; hasFocus = false; }
public Button(string buttonText, SpriteFont font, float x, float y, bool centered, OnMouseDown MouseEvent) : this(buttonText, font, Color.White, Color.White, null, null, x, y, centered, MouseEvent) { }
// Constructors public Button(string buttonText, SpriteFont font, Color mainColor, Color mouseoverColor, float x, float y, bool centered, OnMouseDown MouseEvent) : this(buttonText, font, mainColor, mouseoverColor, null, null, x, y, centered, MouseEvent) { }
// Set the delegate public void SetButtonEvent(OnMouseDown onMouseDownDelegate) { MouseEvent = onMouseDownDelegate; }