Axiom.Samples.SelectMenu.OnCursorMoved C# (CSharp) Метод

OnCursorMoved() публичный Метод

public OnCursorMoved ( Vector2 cursorPos ) : void
cursorPos Vector2
Результат void
		public override void OnCursorMoved( Vector2 cursorPos )
		{
			OverlayManager om = OverlayManager.Instance;

			if ( this.isExpanded )
			{
				if ( this.isDragging )
				{
					Vector2 co = Widget.CursorOffset( this.scrollHandle, cursorPos );
					Real newTop = this.scrollHandle.Top + co.y - this.dragOffset;
					Real lowerBoundary = this.scrollTrack.Height - this.scrollHandle.Height;
					this.scrollHandle.Top = Math.Utility.Clamp<Real>( newTop, lowerBoundary, 0 );

					Real scrollPercentage = Math.Utility.Clamp<Real>( newTop / lowerBoundary, 0, 1 );
					int newIndex = (int)( scrollPercentage * ( this.items.Count - this.itemElements.Count ) + 0.5 );
					if ( newIndex != this.displayIndex )
						DisplayIndex = newIndex;
					return;
				}

				Real l = this.itemElements[ 0 ].DerivedLeft * om.ViewportWidth + 5;
				Real t = this.itemElements[ 0 ].DerivedTop * om.ViewportHeight + 5;
				Real r = l + this.itemElements[ itemElements.Count - 1 ].Width - 10;
				Real b = this.itemElements[ itemElements.Count - 1 ].DerivedTop * om.ViewportHeight +
						 this.itemElements[ itemElements.Count - 1 ].Height - 5;

				if ( cursorPos.x >= l && cursorPos.x <= r && cursorPos.y >= t && cursorPos.y <= b )
				{
					int newIndex = (int)( this.displayIndex + ( cursorPos.y - t ) / ( b - t ) * this.itemElements.Count );
					if ( this.highlightIndex != newIndex )
					{
						this.highlightIndex = newIndex;
						DisplayIndex = this.displayIndex;
					}
				}
			}
			else
			{
				if ( IsCursorOver( this.smallBox, cursorPos, 4 ) )
				{
					this.smallBox.MaterialName = "SdkTrays/MiniTextBox/Over";
					this.smallBox.BorderMaterialName = "SdkTrays/MiniTextBox/Over";
					this.IsCursorOver = true;
				}
				else
				{
					if ( this.IsCursorOver )
					{
						this.smallBox.MaterialName = "SdkTrays/MiniTextBox";
						this.smallBox.BorderMaterialName = "SdkTrays/MiniTextBox";
						this.IsCursorOver = false;
					}
				}
			}

			base.OnCursorMoved( cursorPos );
		}