private void CheckButtonPressed(Func <MouseState, ButtonState> getButtonState, MouseButton button)
        {
            if (getButtonState(_currentState) == ButtonState.Pressed &&
                getButtonState(_previousState) == ButtonState.Released)
            {
                var args = new MouseEventArgs(_gameTime.TotalGameTime, _previousState, _currentState, button);

                MouseDown.Raise(this, args);
                _mouseDownArgs = args;

                if (_previousClickArgs != null)
                {
                    // If the last click was recent
                    var clickMilliseconds = (args.Time - _previousClickArgs.Time).TotalMilliseconds;

                    if (clickMilliseconds <= DoubleClickMilliseconds)
                    {
                        MouseDoubleClicked.Raise(this, args);
                        _hasDoubleClicked = true;
                    }

                    _previousClickArgs = null;
                }
            }
        }
Exemplo n.º 2
0
		public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
			if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
				onMouseDoubleClick (this, e);
			else
				currentInterface.clickTimer.Restart();
			CurrentInterface.eligibleForDoubleClick = null;

			if (CurrentInterface.ActiveWidget == null)
				CurrentInterface.ActiveWidget = this;
			if (this.Focusable && !Interface.FocusOnHover) {
				BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
				if (be.Focused == null) {
					be.Focused = this;
					CurrentInterface.FocusedWidget = this;
				}
			}
			//bubble event to the top
			GraphicObject p = Parent as GraphicObject;
			if (p != null)
				p.onMouseDown(sender,e);

			MouseDown.Raise (this, e);
		}
 /// <summary>
 /// Method triggered when MouseDown event is fired on the TreeListView. Raises MouseDown event.</summary>
 /// <param name="e">Mouse event arguments</param>
 protected virtual void OnMouseDown(MouseEventArgs e)
 {
     MouseDown.Raise(this, e);
 }