|
@@ -3,7 +3,6 @@ using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
using System.Windows.Interactivity;
|
|
using System.Windows.Interactivity;
|
|
-using PixiEditor.Models.Controllers.Shortcuts;
|
|
|
|
|
|
|
|
namespace PixiEditor.Helpers.Behaviours
|
|
namespace PixiEditor.Helpers.Behaviours
|
|
{
|
|
{
|
|
@@ -12,11 +11,19 @@ namespace PixiEditor.Helpers.Behaviours
|
|
// Using a DependencyProperty as the backing store for FillSize. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for FillSize. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty FillSizeProperty =
|
|
public static readonly DependencyProperty FillSizeProperty =
|
|
DependencyProperty.Register(
|
|
DependencyProperty.Register(
|
|
- "FillSize",
|
|
|
|
|
|
+ nameof(FillSize),
|
|
typeof(bool),
|
|
typeof(bool),
|
|
typeof(TextBoxFocusBehavior),
|
|
typeof(TextBoxFocusBehavior),
|
|
new PropertyMetadata(false));
|
|
new PropertyMetadata(false));
|
|
|
|
|
|
|
|
+ // Using a DependencyProperty as the backing store for FillSize. This enables animation, styling, binding, etc...
|
|
|
|
+ public static readonly DependencyProperty SelectOnFocusProperty =
|
|
|
|
+ DependencyProperty.Register(
|
|
|
|
+ nameof(SelectOnFocus),
|
|
|
|
+ typeof(bool),
|
|
|
|
+ typeof(TextBoxFocusBehavior),
|
|
|
|
+ new PropertyMetadata(true));
|
|
|
|
+
|
|
private string oldText; // Value of textbox before editing
|
|
private string oldText; // Value of textbox before editing
|
|
private bool valueConverted; // This bool is used to avoid double convertion if enter is hitted
|
|
private bool valueConverted; // This bool is used to avoid double convertion if enter is hitted
|
|
|
|
|
|
@@ -26,6 +33,12 @@ namespace PixiEditor.Helpers.Behaviours
|
|
set => SetValue(FillSizeProperty, value);
|
|
set => SetValue(FillSizeProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public bool SelectOnFocus
|
|
|
|
+ {
|
|
|
|
+ get => (bool)GetValue(SelectOnFocusProperty);
|
|
|
|
+ set => SetValue(SelectOnFocusProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
protected override void OnAttached()
|
|
protected override void OnAttached()
|
|
{
|
|
{
|
|
base.OnAttached();
|
|
base.OnAttached();
|
|
@@ -74,7 +87,8 @@ namespace PixiEditor.Helpers.Behaviours
|
|
object sender,
|
|
object sender,
|
|
KeyboardFocusChangedEventArgs e)
|
|
KeyboardFocusChangedEventArgs e)
|
|
{
|
|
{
|
|
- AssociatedObject.SelectAll();
|
|
|
|
|
|
+ if (SelectOnFocus)
|
|
|
|
+ AssociatedObject.SelectAll();
|
|
if (FillSize)
|
|
if (FillSize)
|
|
{
|
|
{
|
|
valueConverted = false;
|
|
valueConverted = false;
|
|
@@ -86,7 +100,8 @@ namespace PixiEditor.Helpers.Behaviours
|
|
object sender,
|
|
object sender,
|
|
MouseEventArgs e)
|
|
MouseEventArgs e)
|
|
{
|
|
{
|
|
- AssociatedObject.SelectAll();
|
|
|
|
|
|
+ if (SelectOnFocus)
|
|
|
|
+ AssociatedObject.SelectAll();
|
|
}
|
|
}
|
|
|
|
|
|
private void AssociatedObjectPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
private void AssociatedObjectPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
@@ -127,4 +142,4 @@ namespace PixiEditor.Helpers.Behaviours
|
|
valueConverted = true;
|
|
valueConverted = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|