/// <summary> /// Makes a new instance of <see cref="GlfwMouse"/> class. /// </summary> /// <param name="window">Current context.</param> public GlfwMouse(GlfwWindow window) { handler = window; handler.OnRestore += Handler_OnRestore; cursorCallback = (w, x, y) => { OnMove?.Invoke(this, new MousePositiontEventArgs { Position = new Vector2((float)x, (float)y) }); }; scrollCallback = (w, x, y) => { OnScroll?.Invoke(this, new MouseOffsetEventArgs { Offset = new Vector2((float)x, (float)y) }); }; buttonCallback = (w, button, action, modifiers) => { OnButtonEvent?.Invoke(this, new MouseKeyEventArgs { Key = (MouseButton)button, Action = (KeyState)action, Modifiers = (KeyModifier)modifiers }); }; }
public UI_Button(Camera camera, string text, float x, float y, OnButtonEvent onButtonEvent) : base(camera) { _text = text; Pos.X = x; Pos.Y = y; _buttonEvent = onButtonEvent; _cameraPos = new Vector(); }
public void Update(IFrameBasedClock clock) { while (currentState != null && currentState.Events.Count > 0) { IInputEvent e = currentState.Events.Dequeue(); if (e is InputEvent <MouseKeyEventArgs> keyEvent && keyEvent.Name == "OnButtonEvent") { OnButtonEvent?.Invoke(this, keyEvent.Info); } if (e is InputEvent <MousePositiontEventArgs> modEvent && modEvent.Name == "OnMove") { OnMove?.Invoke(this, modEvent.Info); } if (e is InputEvent <MouseOffsetEventArgs> tyEvent && tyEvent.Name == "OnScroll") { OnScroll?.Invoke(this, tyEvent.Info); } } }
public void UnregisterButtonUpCallback(OnButtonEvent callbackMethod) { OnButtonUp -= callbackMethod; }
public void RegisterButtonUpCallback(OnButtonEvent callbackMethod) { OnButtonUp += callbackMethod; }
public void RegisterButtonHoldCallback(OnButtonEvent callbackMethod) { OnButtonHold += callbackMethod; }
public void RegisterButtonDownCallback(OnButtonEvent callbackMethod) { OnButtonDown += callbackMethod; }
public virtual void ButtonEventAction(UIButtonEventArgs eventArgs) { OnButtonEvent?.Invoke(this, eventArgs); }