fix #172 show not drag to add/cut while clamp
This commit is contained in:
@@ -30,6 +30,12 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
|||||||
private Point? _point;
|
private Point? _point;
|
||||||
protected internal bool _updateFromTextInput;
|
protected internal bool _updateFromTextInput;
|
||||||
|
|
||||||
|
|
||||||
|
protected internal bool _canIncrease = true;
|
||||||
|
|
||||||
|
protected internal bool _canDecrease = true;
|
||||||
|
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> AllowDragProperty = AvaloniaProperty.Register<NumericUpDown, bool>(
|
public static readonly StyledProperty<bool> AllowDragProperty = AvaloniaProperty.Register<NumericUpDown, bool>(
|
||||||
nameof(AllowDrag), defaultValue: false);
|
nameof(AllowDrag), defaultValue: false);
|
||||||
|
|
||||||
@@ -256,10 +262,12 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
|||||||
int d = GetDelta(delta.Value);
|
int d = GetDelta(delta.Value);
|
||||||
if (d > 0)
|
if (d > 0)
|
||||||
{
|
{
|
||||||
|
if (_canIncrease)
|
||||||
Increase();
|
Increase();
|
||||||
}
|
}
|
||||||
else if (d < 0)
|
else if (d < 0)
|
||||||
{
|
{
|
||||||
|
if (_canDecrease)
|
||||||
Decrease();
|
Decrease();
|
||||||
}
|
}
|
||||||
_point = point;
|
_point = point;
|
||||||
@@ -511,6 +519,8 @@ public abstract class NumericUpDownBase<T> : NumericUpDown where T : struct, ICo
|
|||||||
protected override void SetValidSpinDirection()
|
protected override void SetValidSpinDirection()
|
||||||
{
|
{
|
||||||
var validDirection = ValidSpinDirections.None;
|
var validDirection = ValidSpinDirections.None;
|
||||||
|
_canIncrease = false;
|
||||||
|
_canDecrease = false;
|
||||||
if (!IsReadOnly)
|
if (!IsReadOnly)
|
||||||
{
|
{
|
||||||
if (Value is null)
|
if (Value is null)
|
||||||
@@ -520,11 +530,13 @@ public abstract class NumericUpDownBase<T> : NumericUpDown where T : struct, ICo
|
|||||||
if (Value.HasValue && Value.Value.CompareTo(Maximum) < 0)
|
if (Value.HasValue && Value.Value.CompareTo(Maximum) < 0)
|
||||||
{
|
{
|
||||||
validDirection |= ValidSpinDirections.Increase;
|
validDirection |= ValidSpinDirections.Increase;
|
||||||
|
_canIncrease = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Value.HasValue && Value.Value.CompareTo(Minimum) > 0)
|
if (Value.HasValue && Value.Value.CompareTo(Minimum) > 0)
|
||||||
{
|
{
|
||||||
validDirection |= ValidSpinDirections.Decrease;
|
validDirection |= ValidSpinDirections.Decrease;
|
||||||
|
_canDecrease = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_spinner != null)
|
if (_spinner != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user