本文整理汇总了C#中SFML.Window.MouseButtonEventArgs.Location方法的典型用法代码示例。如果您正苦于以下问题:C# MouseButtonEventArgs.Location方法的具体用法?C# MouseButtonEventArgs.Location怎么用?C# MouseButtonEventArgs.Location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Window.MouseButtonEventArgs
的用法示例。
在下文中一共展示了MouseButtonEventArgs.Location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnMouseDown
/// <summary>
/// Handles when a mouse button has been pressed down on this <see cref="Control"/>.
/// This is called immediately before <see cref="Control.OnMouseDown"/>.
/// Override this method instead of using an event hook on <see cref="Control.MouseDown"/> when possible.
/// </summary>
/// <param name="e">The event args.</param>
protected virtual void OnMouseDown(MouseButtonEventArgs e)
{
// Give the control the focus
if ((CanFocus || CanDrag) && GetChild(e.Location(), true) == null)
{
GUIManager.FocusedControl = this;
// Drag the control if possible
if (CanDrag)
{
_dragOffset = e.Location() - Position;
if (!_isDragging)
{
_isDragging = true;
InvokeBeginDrag();
}
}
}
}
示例2: OnClick
/// <summary>
/// Handles when this <see cref="Control"/> was clicked.
/// This is called immediately before <see cref="Control.OnClick"/>.
/// Override this method instead of using an event hook on <see cref="Control.OnClick"/> when possible.
/// </summary>
/// <param name="e">The event args.</param>
protected override void OnClick(MouseButtonEventArgs e)
{
base.OnClick(e);
if (!IsEnabled || !IsVisible)
return;
int lineIndex;
int lineCharIndex;
GetCharacterAtPoint(e.Location(), out lineIndex, out lineCharIndex);
_lines.MoveTo(lineIndex);
CursorLinePosition = lineCharIndex;
}