Refactor Control autofocus to be handled by control type instead of as part of base.OnMouseDown
This commit is contained in:
@@ -236,51 +236,59 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
|
||||
if (button == MouseButton.Left && !_isPressed)
|
||||
{
|
||||
OnPressBegin();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnMouseDown(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
|
||||
if (button == MouseButton.Left && _isPressed)
|
||||
{
|
||||
OnPressEnd();
|
||||
OnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchDown(Vector2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchDown(location, pointerId))
|
||||
return true;
|
||||
|
||||
if (!_isPressed)
|
||||
{
|
||||
OnPressBegin();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnTouchDown(location, pointerId);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTouchUp(Vector2 location, int pointerId)
|
||||
{
|
||||
if (base.OnTouchUp(location, pointerId))
|
||||
return true;
|
||||
|
||||
if (_isPressed)
|
||||
{
|
||||
OnPressEnd();
|
||||
OnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnTouchUp(location, pointerId);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -547,23 +547,25 @@ namespace FlaxEngine.GUI
|
||||
if (button == MouseButton.Left)
|
||||
{
|
||||
_touchDown = true;
|
||||
Focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
|
||||
if (_touchDown && button == MouseButton.Left)
|
||||
{
|
||||
_touchDown = false;
|
||||
ShowPopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -783,10 +783,8 @@ namespace FlaxEngine.GUI
|
||||
var child = _children[i];
|
||||
if (child.Visible && child.Enabled)
|
||||
{
|
||||
// Fire events
|
||||
if (IntersectsChildContent(child, location, out var childLocation))
|
||||
{
|
||||
// Wheel
|
||||
if (child.OnMouseWheel(childLocation, delta))
|
||||
{
|
||||
return true;
|
||||
@@ -794,8 +792,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseWheel(location, delta);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -807,10 +804,8 @@ namespace FlaxEngine.GUI
|
||||
var child = _children[i];
|
||||
if (child.Visible && child.Enabled)
|
||||
{
|
||||
// Fire event
|
||||
if (IntersectsChildContent(child, location, out var childLocation))
|
||||
{
|
||||
// Send event further
|
||||
if (child.OnMouseDown(childLocation, button))
|
||||
{
|
||||
return true;
|
||||
@@ -818,8 +813,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseDown(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -831,10 +825,8 @@ namespace FlaxEngine.GUI
|
||||
var child = _children[i];
|
||||
if (child.Visible && child.Enabled)
|
||||
{
|
||||
// Fire event
|
||||
if (IntersectsChildContent(child, location, out var childLocation))
|
||||
{
|
||||
// Send event further
|
||||
if (child.OnMouseUp(childLocation, button))
|
||||
{
|
||||
return true;
|
||||
@@ -842,8 +834,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -855,10 +846,8 @@ namespace FlaxEngine.GUI
|
||||
var child = _children[i];
|
||||
if (child.Visible && child.Enabled)
|
||||
{
|
||||
// Fire event
|
||||
if (IntersectsChildContent(child, location, out var childLocation))
|
||||
{
|
||||
// Send event further
|
||||
if (child.OnMouseDoubleClick(childLocation, button))
|
||||
{
|
||||
return true;
|
||||
@@ -866,8 +855,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseDoubleClick(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -653,7 +653,7 @@ namespace FlaxEngine.GUI
|
||||
[NoAnimate]
|
||||
public virtual bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
{
|
||||
return _autoFocus && Focus(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -261,6 +261,14 @@ namespace FlaxEngine.GUI
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
return AutoFocus && Focus(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseWheel(Vector2 location, float delta)
|
||||
{
|
||||
|
||||
@@ -169,29 +169,31 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left)
|
||||
{
|
||||
if (_splitterRect.Contains(location))
|
||||
{
|
||||
// Start moving splitter
|
||||
StartTracking();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
|
||||
return base.OnMouseDown(location, button);
|
||||
if (button == MouseButton.Left && _splitterRect.Contains(location))
|
||||
{
|
||||
// Start moving splitter
|
||||
StartTracking();
|
||||
Focus();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseUp(location, button))
|
||||
return true;
|
||||
|
||||
if (_splitterClicked)
|
||||
{
|
||||
EndTracking();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user