protected virtual void OnPress() { if (Pressed != null) { Pressed.Invoke(this); } }
/// <summary> /// Handler invoked on mouse click (left) event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="down">If set to <c>true</c> mouse button is down.</param> protected override void OnMouseClickedLeft(int x, int y, bool down) { if (null == m_Target) { return; } if (down) { m_Held = true; m_HoldPos = m_Target.CanvasPosToLocal(new Point(x, y)); InputHandler.MouseFocus = this; if (Pressed != null) { Pressed.Invoke(this, EventArgs.Empty); } } else { m_Held = false; InputHandler.MouseFocus = null; if (Released != null) { Released.Invoke(this, EventArgs.Empty); } } }
public virtual void SendPressed() { if (IsEnabled == true) { Pressed?.Invoke(this, EventArgs.Empty); } }
private void Hook_KeyPressed(object sender, KeyPressedEventArgs e) { if (Enabled && e.Modifier == Modifier && e.Key == Key) { Pressed?.Invoke(this, EventArgs.Empty); } }
public override void _Input(InputEvent @event) { var eventValue = HandleEvent(@event); if (eventValue.HasValue == false) { return; } foreach (var mapping in InputMap) { if (mapping.Value.ActionMatch(@event)) { if (eventValue.HasValue) { var pressed = IsPressed(mapping.Key); var willBePressed = IsInputValuePressed(eventValue.Value); if (pressed && willBePressed == false) // just released { Released?.Invoke(mapping.Key); } else if (pressed == false && willBePressed) // just pressed { Pressed?.Invoke(mapping.Key); } Actions[mapping.Key] = eventValue.Value; } } } }
protected void OnAction(InputAction.CallbackContext context) { var control = context.control; var device = control.device; var isMouseInput = device is Mouse; var isPenInput = !isMouseInput && device is Pen; // Read our current pointer values. var drag = context.ReadValue <PointerInput>(); if (isMouseInput) { drag.InputId = PointerInputModule.kMouseLeftId; } else if (isPenInput) { drag.InputId = int.MinValue; } if (drag.Contact && !m_Dragging) { Pressed?.Invoke(drag, context.time); m_Dragging = true; } else if (drag.Contact && m_Dragging) { Dragged?.Invoke(drag, context.time); } else { Released?.Invoke(drag, context.time); m_Dragging = false; } }
private void OnPress() { if (Pressed != null) { Pressed.Invoke(this); } }
/// <summary> /// Handler invoked on mouse click (left) event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="down">If set to <c>true</c> mouse button is down.</param> protected override void OnMouseClickedLeft(int x, int y, bool down) { if (down) { IsDepressed = true; InputHandler.MouseFocus = this; if (Pressed != null) { Pressed.Invoke(this, EventArgs.Empty); } base.OnMouseClickedLeft(x, y, true); //not original } else { if (IsHovered && m_Depressed) { OnClicked(x, y); } IsDepressed = false; InputHandler.MouseFocus = null; if (Released != null) { Released.Invoke(this, EventArgs.Empty); } } Redraw(); }
/// <summary> /// Handler invoked on mouse click (left) event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="down">If set to <c>true</c> mouse button is down.</param> protected override void onMouseClickedLeft(int x, int y, bool down) { //base.onMouseClickedLeft(x, y, down); if (down) { IsDepressed = true; InputHandler.MouseFocus = this; if (Pressed != null) { Pressed.Invoke(this, EventArgs.Empty); } } else { if (IsHovered && depressed) { onClicked(x, y); } IsDepressed = false; InputHandler.MouseFocus = null; if (Released != null) { Released.Invoke(this, EventArgs.Empty); } } Redraw(); }
private void onMouseDown(object sender, MouseButtonEventArgs e) { if (e.Button == Mouse.Button.Left && inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height) { if (_state != InteractableState.Down) { if (_downTexture != null) { /*bool update = false; * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) { * update = true; * }*/ Texture = atlas.GetTexture(_downTexture); //if (update) { _hitBox.X = 0.0d; _hitBox.Y = 0.0d; _hitBox.Width = Width; _hitBox.Height = Height; //} } _state = InteractableState.Down; Pressed?.Invoke(this, EventArgs.Empty); } } }
public async Task Activate(int gpioNumber) { try { _console.WriteLine($"Opening GPIO {gpioNumber} ..."); _gpioController.OpenPin(gpioNumber); _console.WriteLine( $"GPIO {gpioNumber} was opened! Initial value: {_gpioController.Read(gpioNumber).ToString()}"); } catch (Exception e) { Console.WriteLine(e); return; } while (true) { var pinValue = _gpioController.Read(gpioNumber); if (pinValue == PinValue.Low) { Pressed?.Invoke(this, EventArgs.Empty); await Task.Delay(400); continue; } await Task.Delay(20); } }
public void Update() { if (!IsEnabled) { return; } if (Input.GetKeyDown(_key)) { Begin?.Invoke(this, _lastPosition = Input.mousePosition); } else if (Input.GetKey(_key)) { Vector3 currentMousePosition = Input.mousePosition; if (_lastPosition != currentMousePosition) { Moved?.Invoke(this, currentMousePosition); _lastPosition = currentMousePosition; } Pressed?.Invoke(this, currentMousePosition); } else if (Input.GetKeyUp(_key)) { Ended?.Invoke(this, Input.mousePosition); _lastPosition = Vector3.zero; } }
/// <summary> /// Handler invoked on mouse click (left) event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="down">If set to <c>true</c> mouse button is down.</param> protected override void OnMouseClickedLeft(int x, int y, bool down) { //base.OnMouseClickedLeft(x, y, down); if (down) { IsDepressed = true; InputHandler.MouseFocus = this; if (Pressed != null) { Pressed.Invoke(this, EventArgs.Empty); } } else { if (IsHovered && m_Depressed && this.GetCanvas().GetControlAt(x, y) == this) { OnClicked(x, y); } IsDepressed = false; InputHandler.MouseFocus = null; if (Released != null) { Released.Invoke(this, EventArgs.Empty); } } Redraw(); }
public void SetPressed(bool press) { if (press) { Pressed?.Invoke(); } }
public virtual void OnPressed(Mouse.Button button) { StyleChanged = true; if (button == Mouse.Button.Left) { IsPressed = true; } Pressed?.Invoke(this, button); if (_doubleClick) { _doubleClick = false; return; } Vector2i currentMPos = Mouse.GetPosition(Form.Window); if (_doubleClickTimer.ElapsedMilliseconds <= 500 && _firstClickPos.Near(currentMPos, 0) && button == Mouse.Button.Left) { _doubleClick = true; OnDoubleClicked(); } if (button == Mouse.Button.Left) { _doubleClickTimer.Restart(); _firstClickPos = currentMPos; } }
/// <summary> /// Handler invoked on mouse click (left) event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="down">If set to <c>true</c> mouse button is down.</param> protected override void OnMouseClickedLeft(int x, int y, bool down) { //base.OnMouseClickedLeft(x, y, down); if (down) { IsDepressed = true; InputHandler.Instance.MouseFocus = this; if (Pressed != null) { Pressed.Invoke(this); } } else { if (IsHovered && m_Depressed) { OnClicked(); } IsDepressed = false; InputHandler.Instance.MouseFocus = null; if (Released != null) { Released.Invoke(this); } } Redraw(); }
private void GpioOnValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { if (args.Edge == GpioPinEdge.FallingEdge) { Pressed?.Invoke(this, EventArgs.Empty); } }
public HotKeyListener(IntPtr hWnd) { HWnd = hWnd; HotKeys = new ConcurrentDictionary <uint, HotKeyEventArgs>(); string atomName = Thread.CurrentThread.ManagedThreadId.ToString("X8") + GetType().FullName; ID = Kernel32.GlobalAddAtom(atomName); Callback = HookManager.WindowCallback(hWnd, (WindowsMessage message, IntPtr wParam, IntPtr lParam) => { if (message == WindowsMessage.HotKey && wParam.ToInt32() == ID) { var hk = (uint)lParam.ToInt32(); if (HotKeys.ContainsKey(hk)) { try { Pressed?.Invoke(this, HotKeys[hk]); } catch { } } return(false); } return(false); }); }
/// <summary> /// Creates and initializes a new instance of the Button class. /// </summary> /// <param name="parent"> /// The EvasObject to which the new Button will be attached as a child. /// </param> /// <since_tizen> preview </since_tizen> public Button(EvasObject parent) : base(parent) { _clicked = new SmartEvent(this, this.RealHandle, "clicked"); _repeated = new SmartEvent(this, this.RealHandle, "repeated"); _pressed = new SmartEvent(this, this.RealHandle, "pressed"); _released = new SmartEvent(this, this.RealHandle, "unpressed"); _clicked.On += (sender, e) => { Clicked?.Invoke(this, EventArgs.Empty); }; _repeated.On += (sender, e) => { Repeated?.Invoke(this, EventArgs.Empty); }; _pressed.On += (sender, e) => { Pressed?.Invoke(this, EventArgs.Empty); }; _released.On += (sender, e) => { Released?.Invoke(this, EventArgs.Empty); }; }
private void PressAndRelease() { Task.Run(() => { Pressed?.Invoke(this, EventArgs.Empty); Released?.Invoke(this, EventArgs.Empty); }); }
/// <summary> /// Creates and initializes a new instance of the Panes class. /// </summary> /// <param name="parent">The EvasObject to which the new Panes will be attached as a child.</param> /// <since_tizen> preview </since_tizen> public Panes(EvasObject parent) : base(parent) { _press = new SmartEvent(this, this.RealHandle, "press"); _unpressed = new SmartEvent(this, this.RealHandle, "unpress"); _press.On += (s, e) => Pressed?.Invoke(this, e); _unpressed.On += (s, e) => Unpressed?.Invoke(this, e); }
private void Raise(ref bool handled) { KeyPressedEventArgs args = new KeyPressedEventArgs(handled); Pressed?.Invoke(this, args); handled = args.Handled; }
private bool OnPressed() { var e = new HandledEventArgs(false); Pressed?.Invoke(this, e); return(e.Handled); }
public override void MouseDown(NSEvent theEvent) { Pressed?.Invoke(); base.MouseDown(theEvent); Released?.Invoke(); }
public override void MouseDown(NSEvent theEvent) { Pressed?.Invoke(this, EventArgs.Empty); base.MouseDown(theEvent); Released?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Invoke the key(s) pressed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="keys">The key(s) pressed.</param> internal void InvokePressed(View sender, Key[] keys) { Pressed?.Invoke(sender, new KeyEventArgs(keys)); if (Command is ICommand cmd && cmd.CanExecute(CommandParameter)) { cmd.Execute(CommandParameter); } }
private void onPressed() { if (AutoCheck) { Checked = !Checked; } Pressed?.Invoke(this, EventArgs.Empty); }
void Read(IAsyncResult result) { if (result.IsCompleted) { var len = _stream.EndRead(result); if (len == 0) { //connection closed //send events Disconnected?.Invoke(this, new ButtonEventArgs() { ButtonName = Name }); //start listening again if (_reconnect) { _client.Close(); _client.Dispose(); _client = new BluetoothClient(); //create a new client - for some reason its not reusable at this point StartListening(); } } else { var messages = _parser.GetMessage(_buffer, len); if (messages != null) { foreach (var message in messages) { if (message.Payload[1] == 1 && message.Payload[25] == 2) { //set events Pressed?.Invoke(this, new ButtonEventArgs() { ButtonName = Name }); } if (message.Payload[1] == 1 && message.Payload[25] == 3) { //set events Released?.Invoke(this, new ButtonEventArgs() { ButtonName = Name }); } } } //read again ReadEvents(); } } }
protected void MessageEvent(object sender, ref Message m, ref bool handled) //Handle WM_Hotkey event { if (m.Msg == (int)Msgs.WmHotkey && m.WParam == (IntPtr)GetType().GetHashCode()) { handled = true; System.Diagnostics.Debug.WriteLine("HOTKEY pressed!"); Pressed?.Invoke(this, EventArgs.Empty); } }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_HOTKEY && _id == wParam.ToInt32()) { Pressed?.Invoke(); handled = false; } return(IntPtr.Zero); }