本文整理汇总了C#中Input.MousePressed方法的典型用法代码示例。如果您正苦于以下问题:C# Input.MousePressed方法的具体用法?C# Input.MousePressed怎么用?C# Input.MousePressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input.MousePressed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleMouse
public virtual void HandleMouse(bool mouseValid, int x, int y, Input input, GuiModule module)
{
Hover = mouseValid && rect.Contains(x, y);
if (Hover && input.MousePressed())
{
var handler = GetSetting("on-click", null);
if (handler != null)
module.ButtonEvent(handler, this);
input.MouseHandled = true;
}
if (Visible)
foreach (var child in children) child.HandleMouse(mouseValid, x, y, input, module);
}
示例2: HandleMouse
public override void HandleMouse(bool mouseValid, int x, int y, Input input, GuiModule module)
{
base.HandleMouse(mouseValid, x, y, input, module);
if (!mouseValid) return;
if (input.MousePressed())
{
if (rect.Contains(x, y))
{
var mouseOffset = y - rect.Y - (handle_size / 2);
mouseStart = y;
var hitPlace = mouseOffset + (spaceSize / 2);
var hitSpace = hitPlace / spaceSize;
position = minimum + (int)(hitSpace * step);
draggingHandle = true;
startPosition = position;
var handler = GetSetting("on-change", null);
if (handler != null)
module.ButtonEvent(handler, this);
}
}
if (input.MouseDown() && draggingHandle)
{
var mouseDelta = y - mouseStart;
var stepsPassed = mouseDelta / spaceSize;
position = startPosition + (int)(stepsPassed * step);
if (position < minimum) position = minimum;
if (position > maximum) position = maximum;
var handler = GetSetting("on-change", null);
if (handler != null)
module.ButtonEvent(handler, this);
}
if (input.MouseReleased())
{
draggingHandle = false;
}
}
示例3: Update
public virtual void Update(Input input, GuiModule module)
{
//Hover = input.MouseInside(rect);
if (Hover && input.MousePressed())
{
if (settings["on-click"] != null)
module.ButtonEvent(settings["on-click"], this);
input.MouseHandled = true;
}
if (Visible)
foreach (var child in children) child.Update(input, module);
}