Fix valid drop not resetting, add debounce timer to highlighting for showing on double click prevention
This commit is contained in:
@@ -24,6 +24,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
public class FlaxObjectRefPickerControl : Control
|
||||
{
|
||||
private ScriptType _type;
|
||||
private ActorTreeNode _linkedTreeNode;
|
||||
private Object _value;
|
||||
private string _valueName;
|
||||
private bool _supportsPickDropDown;
|
||||
@@ -308,22 +309,50 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
if (button == MouseButton.Left)
|
||||
{
|
||||
|
||||
_isMouseDown = false;
|
||||
|
||||
// Highlight actor reference.
|
||||
if (Value is Actor a && !_hasValidDragOver)
|
||||
{
|
||||
ActorTreeNode treeNode = Editor.Instance.Scene.GetActorNode(a).TreeNode;
|
||||
treeNode.ExpandAllParents();
|
||||
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(treeNode, true);
|
||||
treeNode.StartHighlight();
|
||||
if (_linkedTreeNode != null && _linkedTreeNode.Actor == a)
|
||||
{
|
||||
_linkedTreeNode.ExpandAllParents();
|
||||
_linkedTreeNode.StartHighlight();
|
||||
}
|
||||
else
|
||||
{
|
||||
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(a).TreeNode;
|
||||
_linkedTreeNode.ExpandAllParents();
|
||||
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
|
||||
_linkedTreeNode.StartHighlight();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Highlight actor with script reference.
|
||||
if (Value is Script s && !IsDragOver && !_hasValidDragOver)
|
||||
{
|
||||
// TODO: Highlight scripts when Value is a script
|
||||
var scriptActor = s.Actor;
|
||||
if (scriptActor != null)
|
||||
{
|
||||
if (_linkedTreeNode != null && _linkedTreeNode.Actor == scriptActor)
|
||||
{
|
||||
_linkedTreeNode.ExpandAllParents();
|
||||
_linkedTreeNode.StartHighlight();
|
||||
}
|
||||
else
|
||||
{
|
||||
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(scriptActor).TreeNode;
|
||||
_linkedTreeNode.ExpandAllParents();
|
||||
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
|
||||
_linkedTreeNode.StartHighlight();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset valid drag over if still true at this point.
|
||||
if (_hasValidDragOver)
|
||||
_hasValidDragOver = false;
|
||||
}
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
@@ -350,6 +379,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
// Check if has object selected
|
||||
if (_value != null)
|
||||
{
|
||||
if (_linkedTreeNode != null)
|
||||
_linkedTreeNode.StopHighlight();
|
||||
// Select object
|
||||
if (_value is Actor actor)
|
||||
Editor.Instance.SceneEditing.Select(actor);
|
||||
@@ -493,6 +524,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
_value = null;
|
||||
_type = ScriptType.Null;
|
||||
_valueName = null;
|
||||
_linkedTreeNode = null;
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user