fix various issues with console controls
This commit is contained in:
@@ -40,6 +40,8 @@ namespace Game
|
|||||||
private int selectionStartLine;
|
private int selectionStartLine;
|
||||||
public Color TextColor = Color.White;
|
public Color TextColor = Color.White;
|
||||||
|
|
||||||
|
public bool CopyOnSelect = true;
|
||||||
|
|
||||||
public TextWrapping Wrapping;
|
public TextWrapping Wrapping;
|
||||||
|
|
||||||
public ConsoleContentTextBox()
|
public ConsoleContentTextBox()
|
||||||
@@ -67,6 +69,12 @@ namespace Game
|
|||||||
AutoFocus = false;
|
AutoFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnDestroy()
|
||||||
|
{
|
||||||
|
base.OnDestroy();
|
||||||
|
EndMouseCapture();
|
||||||
|
}
|
||||||
|
|
||||||
public int FontHeight => Font.GetFont().Height;
|
public int FontHeight => Font.GetFont().Height;
|
||||||
|
|
||||||
public float HeightMultiplier
|
public float HeightMultiplier
|
||||||
@@ -438,11 +446,15 @@ namespace Game
|
|||||||
bool shiftDown = Root.GetKey(KeyboardKeys.Shift);
|
bool shiftDown = Root.GetKey(KeyboardKeys.Shift);
|
||||||
bool ctrlDown = Root.GetKey(KeyboardKeys.Control);
|
bool ctrlDown = Root.GetKey(KeyboardKeys.Control);
|
||||||
|
|
||||||
if ((shiftDown && key == KeyboardKeys.Delete) || (ctrlDown && key == KeyboardKeys.Insert) ||
|
if (!CopyOnSelect)
|
||||||
(ctrlDown && key == KeyboardKeys.C) || (ctrlDown && key == KeyboardKeys.X))
|
|
||||||
{
|
{
|
||||||
Copy();
|
// This is not working for some reason, the event is never called while selecting text
|
||||||
return true;
|
if ((shiftDown && key == KeyboardKeys.Delete) || (ctrlDown && key == KeyboardKeys.Insert) ||
|
||||||
|
(ctrlDown && key == KeyboardKeys.C) || (ctrlDown && key == KeyboardKeys.X))
|
||||||
|
{
|
||||||
|
Copy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == KeyboardKeys.PageUp)
|
if (key == KeyboardKeys.PageUp)
|
||||||
@@ -463,7 +475,12 @@ namespace Game
|
|||||||
|
|
||||||
//else if (ctrlDown && key == KeyboardKeys.A)
|
//else if (ctrlDown && key == KeyboardKeys.A)
|
||||||
// SelectAll();
|
// SelectAll();
|
||||||
return base.OnKeyDown(key);
|
if (!base.OnKeyDown(key))
|
||||||
|
{
|
||||||
|
inputBox.Focus();
|
||||||
|
return inputBox.OnKeyDown(key);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnMouseWheel(Float2 location, float delta)
|
public override bool OnMouseWheel(Float2 location, float delta)
|
||||||
@@ -493,17 +510,23 @@ namespace Game
|
|||||||
if (!SelectionAllowed)
|
if (!SelectionAllowed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool ret = false;
|
if (!Bounds.Contains(location))
|
||||||
if (button == MouseButton.Left && !IsFocused)
|
|
||||||
{
|
{
|
||||||
Focus();
|
OnSelectingEnd();
|
||||||
ret = true;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
|
if (/*button == MouseButton.Left &&*/ !IsFocused)
|
||||||
|
{
|
||||||
|
//inputBox.Focus();
|
||||||
|
//ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button == MouseButton.Left && Console.Lines.Length > 0)
|
if (button == MouseButton.Left && Console.Lines.Length > 0)
|
||||||
{
|
{
|
||||||
bool selectionStarted = !selectionActive;
|
bool selectionStarted = !selectionActive;
|
||||||
Focus();
|
//Focus();
|
||||||
OnSelectingBegin();
|
OnSelectingBegin();
|
||||||
|
|
||||||
//FlaxEngine.Debug.Log("mousedown, started: " + selectionStarted.ToString());
|
//FlaxEngine.Debug.Log("mousedown, started: " + selectionStarted.ToString());
|
||||||
@@ -547,6 +570,8 @@ namespace Game
|
|||||||
{
|
{
|
||||||
selectionEndLine = hitLine;
|
selectionEndLine = hitLine;
|
||||||
selectionEndChar = hitChar;
|
selectionEndChar = hitChar;
|
||||||
|
if (CopyOnSelect)
|
||||||
|
Copy();
|
||||||
//FlaxEngine.Debug.Log(string.Format("end line {0} char {1}", hitLine, hitChar));
|
//FlaxEngine.Debug.Log(string.Format("end line {0} char {1}", hitLine, hitChar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -558,13 +583,10 @@ namespace Game
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (button == MouseButton.Left)
|
if (button == MouseButton.Left)
|
||||||
{
|
|
||||||
OnSelectingEnd();
|
OnSelectingEnd();
|
||||||
|
if (Bounds.Contains(location))
|
||||||
Focus(inputBox);
|
Focus(inputBox);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMouseLeave()
|
public override void OnMouseLeave()
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ namespace Game
|
|||||||
|
|
||||||
public override void OnLostFocus()
|
public override void OnLostFocus()
|
||||||
{
|
{
|
||||||
// Avoids reseting the caret location
|
// Prevent caret location getting reset back to beginning
|
||||||
bool oldEditing = _isEditing;
|
bool oldEditing = _isEditing;
|
||||||
_isEditing = false;
|
_isEditing = false;
|
||||||
base.OnLostFocus();
|
base.OnLostFocus();
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ namespace Game
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly InputEvent onExit = new InputEvent("Exit");
|
private InputEvent onExit;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
//FlaxEngine.Debug.Log("ConsolePlugin initialized");
|
//FlaxEngine.Debug.Log("ConsolePlugin initialized");
|
||||||
Console.Init();
|
Console.Init();
|
||||||
|
|
||||||
|
onExit = new InputEvent("Exit");
|
||||||
onExit.Triggered += () =>
|
onExit.Triggered += () =>
|
||||||
{
|
{
|
||||||
if (Console.IsSafeToQuit)
|
if (Console.IsSafeToQuit)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace Game
|
|||||||
IsReadOnly = false;
|
IsReadOnly = false;
|
||||||
CaretColor = new Color(1f, 1f, 1f, 1f);
|
CaretColor = new Color(1f, 1f, 1f, 1f);
|
||||||
AutoFocus = true;
|
AutoFocus = true;
|
||||||
|
EndEditOnClick = false;
|
||||||
|
|
||||||
_layout = TextLayoutOptions.Default;
|
_layout = TextLayoutOptions.Default;
|
||||||
_layout.VerticalAlignment = IsMultiline ? TextAlignment.Near : TextAlignment.Center;
|
_layout.VerticalAlignment = IsMultiline ? TextAlignment.Near : TextAlignment.Center;
|
||||||
|
|||||||
Reference in New Issue
Block a user