UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SNumericEntryBox.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Misc/Attribute.h"
7#include "InputCoreTypes.h"
8#include "Layout/Margin.h"
10#include "Layout/Visibility.h"
11#include "Widgets/SNullWidget.h"
13#include "Styling/SlateColor.h"
14#include "Input/Events.h"
15#include "Input/Reply.h"
16#include "Widgets/SWidget.h"
18#include "Styling/CoreStyle.h"
20#include "Widgets/SBoxPanel.h"
22#include "Styling/SlateTypes.h"
29
35template<typename NumericType>
37{
38public:
39
45
47 DECLARE_DELEGATE_OneParam(FOnValueChanged, NumericType /*NewValue*/);
48
50 DECLARE_DELEGATE_TwoParams(FOnValueCommitted, NumericType /*NewValue*/, ETextCommit::Type /*CommitType*/);
51
54
57
60
61 enum class ELabelLocation
62 {
63 // Outside the bounds of the editable area of this box. Usually preferred for text based labels
64 Outside,
65 // Inside the bounds of the editable area of this box. Usually preferred for non-text based labels
66 // when a spin box is used the label will appear on top of the spin box in this case
67 Inside
68 };
69public:
70
72 : _EditableTextBoxStyle( &FAppStyle::Get().GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox") )
73 , _SpinBoxStyle(&FAppStyle::Get().GetWidgetStyle<FSpinBoxStyle>("NumericEntrySpinBox") )
74 , _Label()
78 , _LabelPadding(FMargin(3.f,0.f) )
79 , _BorderForegroundColor(FAppStyle::Get().GetWidgetStyle<FSpinBoxStyle>("NumericEntrySpinBox").ForegroundColor)
83 , _ShiftMultiplier(10.f)
84 , _CtrlMultiplier(0.1f)
87 , _Delta(NumericType(0))
88 , _MinFractionalDigits(DefaultMinFractionalDigits)
89 , _MaxFractionalDigits(DefaultMaxFractionalDigits)
90 , _MinValue(TNumericLimits<NumericType>::Lowest())
91 , _MaxValue(TNumericLimits<NumericType>::Max())
92 , _MinSliderValue(NumericType(0))
93 , _MaxSliderValue(NumericType(100))
94 , _SliderExponent(1.f)
101 , _TogglePadding(FMargin(1.f,0.f,1.f,0.f) )
103 {}
104
106 SLATE_STYLE_ARGUMENT( FEditableTextBoxStyle, EditableTextBoxStyle )
107
108
109 SLATE_STYLE_ARGUMENT( FSpinBoxStyle, SpinBoxStyle )
110
111
112 SLATE_NAMED_SLOT( FArguments, Label )
116 SLATE_ATTRIBUTE(ETextJustify::Type, Justification)
117
120 SLATE_ARGUMENT( FMargin, LabelPadding )
124 SLATE_ARGUMENT( FSlateColor, BorderBackgroundColor )
128 SLATE_ARGUMENT( FText, UndeterminedString )
133 SLATE_ATTRIBUTE_DEPRECATED( int32, ShiftMouseMovePixelPerDelta, 5.4, "Shift Mouse Move Pixel Per Delta is deprecated, please use ShiftMultiplier" )
135 SLATE_ATTRIBUTE( float, ShiftMultiplier )
137 SLATE_ATTRIBUTE( float, CtrlMultiplier )
139 SLATE_ATTRIBUTE( int32, LinearDeltaSensitivity)
141 SLATE_ATTRIBUTE(bool, SupportDynamicSliderMaxValue)
143 SLATE_ATTRIBUTE(bool, SupportDynamicSliderMinValue)
145 SLATE_EVENT(FOnDynamicSliderMinMaxValueChanged, OnDynamicSliderMaxValueChanged)
147 SLATE_EVENT(FOnDynamicSliderMinMaxValueChanged, OnDynamicSliderMinValueChanged)
149 SLATE_ATTRIBUTE( NumericType, Delta )
151 SLATE_ATTRIBUTE(TOptional< int32 >, MinFractionalDigits)
153 SLATE_ATTRIBUTE(TOptional< int32 >, MaxFractionalDigits)
155 SLATE_ATTRIBUTE( TOptional< NumericType >, MinValue )
157 SLATE_ATTRIBUTE( TOptional< NumericType >, MaxValue )
159 SLATE_ATTRIBUTE( TOptional< NumericType >, MinSliderValue )
161 SLATE_ATTRIBUTE( TOptional< NumericType >, MaxSliderValue )
163 SLATE_ATTRIBUTE( float, SliderExponent )
165 SLATE_ATTRIBUTE(NumericType, SliderExponentNeutralValue )
169 SLATE_ARGUMENT(bool, PreventThrottling)
173 SLATE_ATTRIBUTE( TOptional< NumericType >, WheelStep )
175 SLATE_ATTRIBUTE( float, MinDesiredValueWidth )
179 SLATE_EVENT( FOnValueChanged, OnValueChanged )
181 SLATE_EVENT( FOnValueCommitted, OnValueCommitted )
183 SLATE_EVENT( FOnUndeterminedValueChanged, OnUndeterminedValueChanged )
185 SLATE_EVENT( FOnUndeterminedValueCommitted, OnUndeterminedValueCommitted )
187 SLATE_EVENT( FSimpleDelegate, OnBeginSliderMovement )
189 SLATE_EVENT( FOnValueChanged, OnEndSliderMovement )
203 SLATE_ATTRIBUTE(TOptional<FTextFormat>, ToolTipTextFormat)
204
207 {
208 }
209
210 void Construct( const FArguments& InArgs )
211 {
212 check(InArgs._EditableTextBoxStyle);
213
214 OnValueChanged = InArgs._OnValueChanged;
215 OnValueCommitted = InArgs._OnValueCommitted;
216 OnUndeterminedValueChanged = InArgs._OnUndeterminedValueChanged;
217 OnUndeterminedValueCommitted = InArgs._OnUndeterminedValueCommitted;
218 ValueAttribute = InArgs._Value;
219 UndeterminedString = InArgs._UndeterminedString;
220 MinDesiredValueWidth = InArgs._MinDesiredValueWidth;
221 BorderImageNormal = &InArgs._EditableTextBoxStyle->BackgroundImageNormal;
222 BorderImageHovered = &InArgs._EditableTextBoxStyle->BackgroundImageHovered;
223 BorderImageFocused = &InArgs._EditableTextBoxStyle->BackgroundImageFocused;
224 Interface = InArgs._TypeInterface.IsValid() ? InArgs._TypeInterface : MakeShareable( new TDefaultNumericTypeInterface<NumericType> );
225
226 if (InArgs._TypeInterface.IsValid() && Interface->GetOnSettingChanged())
227 {
228 Interface->GetOnSettingChanged()->AddSP(this, &SNumericEntryBox::ResetCachedValueString);
229 }
230
231 MinFractionalDigits = (InArgs._MinFractionalDigits.Get().IsSet()) ? InArgs._MinFractionalDigits : DefaultMinFractionalDigits;
232 MaxFractionalDigits = (InArgs._MaxFractionalDigits.Get().IsSet()) ? InArgs._MaxFractionalDigits : DefaultMaxFractionalDigits;
233 SetMinFractionalDigits(MinFractionalDigits);
234 SetMaxFractionalDigits(MaxFractionalDigits);
235
236 ToolTipTextFormat = InArgs._ToolTipTextFormat;
237
238 CachedExternalValue = ValueAttribute.Get();
239 if (CachedExternalValue.IsSet())
240 {
241 CachedValueString = Interface->ToString(CachedExternalValue.GetValue());
242 }
243 bCachedValueStringDirty = false;
244
245 const bool bDisplayToggle = InArgs._DisplayToggle;
247 {
248 SAssignNew(ToggleCheckBox, SCheckBox)
249 .Padding(FMargin(0.f, 0.f, 2.f, 0.f))
250 .IsChecked(InArgs._ToggleChecked)
251 .OnCheckStateChanged(this, &SNumericEntryBox::HandleToggleCheckBoxChanged, InArgs._OnToggleChanged);
252 }
253
254 const bool bAllowSpin = InArgs._AllowSpin;
256
257 if( bAllowSpin )
258 {
260 .Style(InArgs._SpinBoxStyle)
261 .Font(InArgs._Font.IsSet() ? InArgs._Font : InArgs._EditableTextBoxStyle->TextStyle.Font)
263 .Delta(InArgs._Delta)
264 .ShiftMultiplier(InArgs._ShiftMultiplier)
265 .CtrlMultiplier(InArgs._CtrlMultiplier)
266 .LinearDeltaSensitivity(InArgs._LinearDeltaSensitivity)
267 .SupportDynamicSliderMaxValue(InArgs._SupportDynamicSliderMaxValue)
268 .SupportDynamicSliderMinValue(InArgs._SupportDynamicSliderMinValue)
269 .OnDynamicSliderMaxValueChanged(InArgs._OnDynamicSliderMaxValueChanged)
270 .OnDynamicSliderMinValueChanged(InArgs._OnDynamicSliderMinValueChanged)
271 .OnValueChanged(OnValueChanged)
272 .OnValueCommitted(OnValueCommitted)
273 .MinFractionalDigits(MinFractionalDigits)
274 .MaxFractionalDigits(MaxFractionalDigits)
275 .MinSliderValue(InArgs._MinSliderValue)
276 .MaxSliderValue(InArgs._MaxSliderValue)
277 .MaxValue(InArgs._MaxValue)
278 .MinValue(InArgs._MinValue)
279 .ContextMenuExtender(InArgs._ContextMenuExtender)
280 .SliderExponent(InArgs._SliderExponent)
281 .SliderExponentNeutralValue(InArgs._SliderExponentNeutralValue)
282 .EnableWheel(InArgs._AllowWheel)
283 .PreventThrottling(InArgs._PreventThrottling)
284 .BroadcastValueChangesPerKey(InArgs._BroadcastValueChangesPerKey)
285 .WheelStep(InArgs._WheelStep)
286 .OnBeginSliderMovement(InArgs._OnBeginSliderMovement)
287 .OnEndSliderMovement(InArgs._OnEndSliderMovement)
288 .MinDesiredWidth(InArgs._MinDesiredValueWidth)
289 .TypeInterface(Interface)
291 }
292
293 // Always create an editable text box. In the case of an undetermined value being passed in, we cant use the spinbox.
294 SAssignNew(EditableText, SEditableText)
297 .ColorAndOpacity(InArgs._EditableTextBoxStyle->ForegroundColor)
298 .Visibility(bAllowSpin ? EVisibility::Collapsed : EVisibility::Visible)
299 .Font(InArgs._Font.IsSet() ? InArgs._Font : InArgs._EditableTextBoxStyle->TextStyle.Font)
300 .SelectAllTextWhenFocused(true)
301 .ClearKeyboardFocusOnCommit(false)
304 .SelectAllTextOnCommit(true)
305 .ContextMenuExtender(InArgs._ContextMenuExtender)
306 .Justification(InArgs._Justification)
307 .MinDesiredWidth(InArgs._MinDesiredValueWidth);
308
310
311 // Add the spin box if we have one
312 if( bAllowSpin )
313 {
314 Overlay->AddSlot()
315 .HAlign(HAlign_Fill)
316 .VAlign(VAlign_Center)
317 [
318 SpinBox.ToSharedRef()
319 ];
320 }
321
322
323 TAttribute<FMargin> TextMargin = InArgs._OverrideTextMargin.IsSet() ? InArgs._OverrideTextMargin : InArgs._EditableTextBoxStyle->Padding;
324
325 Overlay->AddSlot()
326 .HAlign(HAlign_Fill)
327 .VAlign(VAlign_Center)
328 .Padding(TextMargin)
329 [
330 EditableText.ToSharedRef()
331 ];
332
334
335 const bool bHasLabel = InArgs._Label.Widget != SNullWidget::NullWidget;
336
337 bool bHasInsideLabel = false;
338 if (bHasLabel && InArgs._LabelLocation == ELabelLocation::Inside)
339 {
340 bHasInsideLabel = true;
341
342 Overlay->AddSlot()
343 .HAlign(HAlign_Left)
344 .VAlign(InArgs._LabelVAlign)
345 .Padding(InArgs._LabelPadding)
346 [
347 InArgs._Label.Widget
348 ];
349 }
350
351
352 if (bAllowSpin && !bHasInsideLabel)
353 {
355 }
356 else
357 {
361 .BorderBackgroundColor(InArgs._BorderBackgroundColor)
362 .ForegroundColor(InArgs._BorderForegroundColor)
363 .Padding(0.f)
364 [
365 Overlay
366 ];
367 }
368
370 {
372 {
374 [
377 .AutoWidth()
378 .HAlign(HAlign_Fill)
379 .VAlign(VAlign_Center)
380 .Padding(InArgs._TogglePadding)
381 [
382 ToggleCheckBox.ToSharedRef()
383 ]
385 [
386 MainContents.ToSharedRef()
387 ]
388 ];
389 }
390 else
391 {
393 [
394 MainContents.ToSharedRef()
395 ];
396 }
397 }
398 else
399 {
401
402 HorizontalBox->AddSlot()
403 .AutoWidth()
404 .HAlign(HAlign_Left)
405 .VAlign(InArgs._LabelVAlign)
406 .Padding(InArgs._LabelPadding)
407 [
408 InArgs._Label.Widget
409 ];
410
412 {
413 HorizontalBox->AddSlot()
414 .AutoWidth()
415 .HAlign(HAlign_Fill)
416 .VAlign(VAlign_Center)
417 .Padding(InArgs._TogglePadding)
418 [
419 ToggleCheckBox.ToSharedRef()
420 ];
421 }
422
423 HorizontalBox->AddSlot()
424 [
425 MainContents.ToSharedRef()
426 ];
427
429 [
430 HorizontalBox
431 ];
432 }
433
434 if (bDisplayToggle)
435 {
436 HandleToggleCheckBoxChanged(InArgs._ToggleChecked.Get(), FOnCheckStateChanged());
437 }
438 }
439
440 static TSharedRef<SWidget> BuildLabel(TAttribute<FText> LabelText, const FSlateColor& ForegroundColor, const FSlateColor& BackgroundColor)
441 {
442 return
445 .BorderImage(FCoreStyle::Get().GetBrush("NumericEntrySpinBox.Decorator"))
446 .BorderBackgroundColor(BackgroundColor)
447 .ForegroundColor(ForegroundColor)
448 .VAlign(VAlign_Center)
449 .HAlign(HAlign_Left)
450 .Padding(FMargin(1.f, 0.f, 6.f, 0.f))
451 [
453 .Text(LabelText)
454 ];
455 }
456
457
459 {
460 return
463 .BorderImage(FAppStyle::Get().GetBrush("NumericEntrySpinBox.NarrowDecorator"))
464 .BorderBackgroundColor(LabelColor)
465 .HAlign(HAlign_Left)
466 .Padding(FMargin(2.0f, 0.0f, 0.0f, 0.0f));
467 }
468
469
471 TSharedPtr<SWidget> GetSpinBox() const { return SpinBox; }
472
474 int32 GetMinFractionalDigits() const { return Interface->GetMinFractionalDigits(); }
476 {
477 Interface->SetMinFractionalDigits((InMinFractionalDigits.Get().IsSet()) ? InMinFractionalDigits.Get() : MinFractionalDigits);
478 bCachedValueStringDirty = true;
479 }
480
482 int32 GetMaxFractionalDigits() const { return Interface->GetMaxFractionalDigits(); }
484 {
485 Interface->SetMaxFractionalDigits((InMaxFractionalDigits.Get().IsSet()) ? InMaxFractionalDigits.Get() : MaxFractionalDigits);
486 bCachedValueStringDirty = true;
487 }
488
489private:
490
491 //~ SWidget Interface
492
493 virtual bool SupportsKeyboardFocus() const override
494 {
495 return StaticCastSharedPtr<SWidget>(EditableText)->SupportsKeyboardFocus();
496 }
497
498 virtual FReply OnFocusReceived( const FGeometry& MyGeometry, const FFocusEvent& InFocusEvent ) override
499 {
500 FReply Reply = FReply::Handled();
501
502 // The widget to forward focus to changes depending on whether we have a SpinBox or not.
504 if (SpinBox.IsValid() && SpinBox->GetVisibility() == EVisibility::Visible)
505 {
506 FocusWidget = SpinBox;
507 }
508 else
509 {
510 FocusWidget = EditableText;
511 }
512
513 if ( InFocusEvent.GetCause() != EFocusCause::Cleared )
514 {
515 // Forward keyboard focus to our chosen widget
516 Reply.SetUserFocus(FocusWidget.ToSharedRef(), InFocusEvent.GetCause());
517 }
518
519 return Reply;
520 }
521
522 virtual FReply OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent ) override
523 {
524 FKey Key = InKeyEvent.GetKey();
525
526 if( Key == EKeys::Escape && EditableText->HasKeyboardFocus() )
527 {
529 }
530
531 return FReply::Unhandled();
532 }
533
534private:
535
539 FString GetLabel() const
540 {
541 // Should always be set if this is being called
542 return LabelAttribute.Get().GetValue();
543 }
544
548 NumericType OnGetValueForSpinBox() const
549 {
550 const auto& Value = ValueAttribute.Get();
551
552 // Get the value or 0 if its not set
553 if( Value.IsSet() == true )
554 {
555 return Value.GetValue();
556 }
557
558 return 0;
559 }
560
561 void SetCachedString(const NumericType CurrentValue)
562 {
563 if (!CachedExternalValue.IsSet() || CachedExternalValue.GetValue() != CurrentValue || bCachedValueStringDirty)
564 {
565 CachedExternalValue = CurrentValue;
566 CachedValueString = Interface->ToString(CurrentValue);
567 bCachedValueStringDirty = false;
568 }
569 }
570
571 FString GetCachedString(const NumericType CurrentValue) const
572 {
573 const bool bUseCachedString = CachedExternalValue.IsSet() && CurrentValue == CachedExternalValue.GetValue() && !bCachedValueStringDirty;
574 return bUseCachedString ? CachedValueString : Interface->ToString(CurrentValue);
575 }
576
577 FText GetToolTipText() const
578 {
579 const TOptional<NumericType>& Value = ValueAttribute.Get();
580
581#if WITH_EDITOR
582 if constexpr (std::is_floating_point_v<NumericType>)
583 {
584 if (Value.IsSet() && CachedValueString.Contains(TEXT("...")))
585 {
586 NumericType NumericValue = Value.GetValue();
587 FString ValueScientificStr = FString::Printf(TEXT("%e"), NumericValue);
588
589 // Dev Note: If you are seeing this message when not expected it can mean the following:
590 // 1. Simple content / value change is needed assuming the ~1e-16 off value is not desired.
591 // 2. If the above doesn't fix the issue, then there probably is an editor customization / some data writer that needs fixing
592 // 3. If the value is a true denorm, smaller than 1.175e-38 / 2.225e-307 for floats / doubles respectively. There is a larger issue.
593 // In this case, it is possible that you may be reading from garbage / random memory not intended for floating point types.
594
595 return FText::Format(NSLOCTEXT("SNumericEntryBox", "NearZeroWarning_ToolTip", "Exact value: {0}. Set value or reimport after updating source content to change."), FText::FromString(ValueScientificStr));
596 }
597 }
598#endif // WITH_EDITOR
599
600 if (Value.IsSet() == true)
601 {
602 NumericType CurrentValue = Value.GetValue();
603
604 FText CurrentValueText = FText::FromString(GetCachedString(CurrentValue));
605
606 if (ToolTipTextFormat.Get().IsSet())
607 {
608 return FText::Format(ToolTipTextFormat.Get().GetValue(), CurrentValueText);
609 }
610
611 return CurrentValueText;
612 }
613
614 return FText::GetEmpty();
615 }
616
620 FText OnGetValueForTextBox() const
621 {
622 if( EditableText->GetVisibility() == EVisibility::Visible )
623 {
624 const TOptional<NumericType>& Value = ValueAttribute.Get();
625 if (Value.IsSet() == true)
626 {
627 return FText::FromString(GetCachedString(Value.GetValue()));
628 }
629 else
630 {
631 return UndeterminedString;
632 }
633 }
634
635 // The box isnt visible, just return an empty Text
636 return FText::GetEmpty();
637 }
638
639
643 void OnTextChanged( const FText& NewValue )
644 {
645 const auto& Value = ValueAttribute.Get();
646
647 if (Value.IsSet() || !OnUndeterminedValueChanged.IsBound())
648 {
649 SendChangesFromText( NewValue, false, ETextCommit::Default );
650 }
651 else
652 {
653 OnUndeterminedValueChanged.Execute(NewValue);
654 }
655 }
656
660 void OnTextCommitted( const FText& NewValue, ETextCommit::Type CommitInfo )
661 {
662 const auto& Value = ValueAttribute.Get();
663
664 if (Value.IsSet() || !OnUndeterminedValueCommitted.IsBound())
665 {
666 SendChangesFromText( NewValue, true, CommitInfo );
667 }
668 else
669 {
670 OnUndeterminedValueCommitted.Execute(NewValue, CommitInfo);
671 }
672 }
673
677 const FSlateBrush* GetBorderImage() const
678 {
680
681 if (SpinBox.IsValid() && SpinBox->GetVisibility() == EVisibility::Visible)
682 {
683 EditingWidget = SpinBox;
684 }
685 else
686 {
687 EditingWidget = EditableText;
688 }
689
690 if ( EditingWidget->HasKeyboardFocus() )
691 {
692 return BorderImageFocused;
693 }
694
695 if ( EditingWidget->IsHovered() )
696 {
697 return BorderImageHovered;
698 }
699
700 return BorderImageNormal;
701 }
702
709 void SendChangesFromText( const FText& NewValue, bool bCommit, ETextCommit::Type CommitInfo )
710 {
711 if (NewValue.IsEmpty())
712 {
713 return;
714 }
715
716 TOptional<NumericType> ExistingValue = ValueAttribute.Get();
717 TOptional<NumericType> NumericValue = Interface->FromString(NewValue.ToString(), ExistingValue.Get(0));
718
719 if (NumericValue.IsSet())
720 {
721 SetCachedString(NumericValue.GetValue());
722
723 if (bCommit)
724 {
725 OnValueCommitted.ExecuteIfBound(NumericValue.GetValue(), CommitInfo);
726 }
727 else
728 {
729 OnValueChanged.ExecuteIfBound(NumericValue.GetValue());
730 }
731 }
732 }
733
737 virtual void Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) override
738 {
739 // Update the cached value, if needed.
740#if WITH_EDITOR
741 if constexpr (std::is_floating_point_v<NumericType>)
742 {
743 if (!GetPersistentState().bIsInGameLayer && !Interface->GetIndicateNearlyInteger())
744 {
745 Interface->SetIndicateNearlyInteger(true);
746 bCachedValueStringDirty = true;
747
748 if (SpinBox.IsValid())
749 {
750 SpinBox->ResetCachedValueString();
751 }
752 }
753 }
754#endif // WITH_EDITOR
755
756 const TOptional<NumericType>& Value = ValueAttribute.Get();
757 if (Value.IsSet() == true)
758 {
759 SetCachedString(Value.GetValue());
760 }
761
762 // Visibility toggle only matters if the spinbox is used
763 if (SpinBox.IsValid())
764 {
765 if (Value.IsSet() == true)
766 {
767 if (SpinBox->GetVisibility() != EVisibility::Visible)
768 {
769 // Set the visibility of the spinbox to visible if we have a valid value
770 SpinBox->SetVisibility( EVisibility::Visible );
771 // The text box should be invisible
772 EditableText->SetVisibility( EVisibility::Collapsed );
773 }
774 }
775 else
776 {
777 // The value isn't set so the spinbox should be hidden and the text box shown
778 SpinBox->SetVisibility(EVisibility::Collapsed);
779 EditableText->SetVisibility(EVisibility::Visible);
780 }
781 }
782 }
783
784 bool IsToggleEnabled() const
785 {
786 if(!IsEnabled())
787 {
788 return false;
789 }
790 return ToggleCheckBox->IsChecked();
791 }
792
793 void HandleToggleCheckBoxChanged(ECheckBoxState InCheckState, FOnCheckStateChanged OnToggleChanged) const
794 {
795 if(SpinBox.IsValid())
796 {
797 SpinBox->SetEnabled(InCheckState == ECheckBoxState::Checked);
798 }
799 if(EditableText.IsValid())
800 {
802 }
803 if(OnToggleChanged.IsBound())
804 {
806 }
807 }
808
809 void ResetCachedValueString()
810 {
811 if (ValueAttribute.Get().IsSet())
812 {
813 bCachedValueStringDirty = true;
814 }
815 }
816
817private:
818
820 static const int32 DefaultMinFractionalDigits;
821
823 static const int32 DefaultMaxFractionalDigits;
824
826 TAttribute< TOptional<FString > > LabelAttribute;
828 TAttribute< TOptional<NumericType> > ValueAttribute;
830 TSharedPtr<SCheckBox> ToggleCheckBox;
834 TSharedPtr<SEditableText> EditableText;
836 FOnValueChanged OnValueChanged;
838 FOnValueCommitted OnValueCommitted;
840 FOnUndeterminedValueChanged OnUndeterminedValueChanged;
842 FOnUndeterminedValueCommitted OnUndeterminedValueCommitted;
844 FText UndeterminedString;
846 const FSlateBrush* BorderImageNormal;
848 const FSlateBrush* BorderImageHovered;
850 const FSlateBrush* BorderImageFocused;
852 TAttribute<float> MinDesiredValueWidth;
856 TOptional<NumericType> CachedExternalValue;
858 FString CachedValueString;
860 bool bCachedValueStringDirty;
861 TAttribute< TOptional<int32> > MinFractionalDigits;
862 TAttribute< TOptional<int32> > MaxFractionalDigits;
863 TAttribute< TOptional<FTextFormat> > ToolTipTextFormat;
864};
865
866
867template <typename NumericType>
869
870template <typename NumericType>
872
873template <typename NumericType>
875
876template <typename NumericType>
878
879template <typename NumericType>
881
882template<typename NumericType>
884
885template<typename NumericType>
887
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
SharedPointerInternals::TRawPtrProxy< ObjectType > MakeShareable(ObjectType *InObject)
Definition SharedPointer.h:1947
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define SLATE_NAMED_SLOT(DeclarationType, SlotName)
Definition DeclarativeSyntaxSupport.h:437
#define SLATE_STYLE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:280
#define SAssignNew(ExposeAs, WidgetType,...)
Definition DeclarativeSyntaxSupport.h:41
#define SNew(WidgetType,...)
Definition DeclarativeSyntaxSupport.h:37
#define SLATE_ATTRIBUTE(AttrType, AttrName)
Definition DeclarativeSyntaxSupport.h:192
#define SLATE_ATTRIBUTE_DEPRECATED(AttrType, AttrName, DeprecationVersion, DeprecationMessage)
Definition DeclarativeSyntaxSupport.h:199
#define SLATE_EVENT(DelegateName, EventName)
Definition DeclarativeSyntaxSupport.h:458
#define SLATE_END_ARGS()
Definition DeclarativeSyntaxSupport.h:116
#define SLATE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:208
return true
Definition ExternalRpcRegistry.cpp:601
#define NSLOCTEXT(InNamespace, InKey, InTextLiteral)
Definition Internationalization.h:300
EVerticalAlignment
Definition SlateEnums.h:194
ECheckBoxState
Definition SlateTypes.h:65
Definition AppStyle.h:24
static SLATECORE_API const ISlateStyle & Get()
Definition AppStyle.cpp:10
static const ISlateStyle & Get()
Definition CoreStyle.h:33
Definition Reply.h:24
static FReply Unhandled()
Definition Reply.h:241
SLATECORE_API FReply & SetUserFocus(TSharedRef< SWidget > GiveMeFocus, EFocusCause ReasonFocusIsChanging=EFocusCause::SetDirectly, bool bInAllUsers=false)
Definition Reply.cpp:40
static FReply Handled()
Definition Reply.h:233
Definition Text.h:278
Definition Text.h:385
CORE_API bool IsEmpty() const
Definition Text.cpp:320
static CORE_API FText FromString(const ANSICHAR *String)
Definition Text.cpp:1081
static CORE_API const FText & GetEmpty()
Definition Text.cpp:252
static CORE_API FText Format(FTextFormat Fmt, const FFormatNamedArguments &InArguments)
Definition Text.cpp:469
CORE_API const FString & ToString() const
Definition Text.cpp:1263
Definition SBorder.h:31
Definition SCheckBox.h:30
bool IsChecked() const
Definition SCheckBox.h:191
Definition SCompoundWidget.h:22
FCompoundWidgetOneChildSlot ChildSlot
Definition SCompoundWidget.h:113
Definition SEditableText.h:38
Definition SBoxPanel.h:171
static FSlot::FSlotArguments Slot()
Definition SBoxPanel.h:272
static SLATECORE_API TSharedRef< class SWidget > NullWidget
Definition SNullWidget.h:22
Definition SNumericEntryBox.h:37
DECLARE_DELEGATE_TwoParams(FOnUndeterminedValueCommitted, FText, ETextCommit::Type)
DECLARE_DELEGATE_OneParam(FOnValueChanged, NumericType)
static TSharedRef< SWidget > BuildLabel(TAttribute< FText > LabelText, const FSlateColor &ForegroundColor, const FSlateColor &BackgroundColor)
Definition SNumericEntryBox.h:440
SLATE_BEGIN_ARGS(SNumericEntryBox< NumericType >)
Definition SNumericEntryBox.h:71
static const FLinearColor BlueLabelBackgroundColor
Definition SNumericEntryBox.h:42
int32 GetMinFractionalDigits() const
Definition SNumericEntryBox.h:474
void SetMinFractionalDigits(const TAttribute< TOptional< int32 > > &InMinFractionalDigits)
Definition SNumericEntryBox.h:475
static const FLinearColor LilacLabelBackgroundColor
Definition SNumericEntryBox.h:43
DECLARE_DELEGATE_OneParam(FOnUndeterminedValueChanged, FText)
static TSharedRef< SWidget > BuildNarrowColorLabel(FLinearColor LabelColor)
Definition SNumericEntryBox.h:458
ELabelLocation
Definition SNumericEntryBox.h:62
static const FText DefaultUndeterminedString
Definition SNumericEntryBox.h:44
int32 GetMaxFractionalDigits() const
Definition SNumericEntryBox.h:482
DECLARE_DELEGATE_TwoParams(FOnValueCommitted, NumericType, ETextCommit::Type)
static const FLinearColor RedLabelBackgroundColor
Definition SNumericEntryBox.h:40
void SetMaxFractionalDigits(const TAttribute< TOptional< int32 > > &InMaxFractionalDigits)
Definition SNumericEntryBox.h:483
void Construct(const FArguments &InArgs)
Definition SNumericEntryBox.h:210
static const FLinearColor GreenLabelBackgroundColor
Definition SNumericEntryBox.h:41
DECLARE_DELEGATE_FourParams(FOnDynamicSliderMinMaxValueChanged, NumericType, TWeakPtr< SWidget >, bool, bool)
TSharedPtr< SWidget > GetSpinBox() const
Definition SNumericEntryBox.h:471
Definition SOverlay.h:44
Definition SSpinBox.h:64
Definition STextBlock.h:45
virtual SLATECORE_API void SetVisibility(TAttribute< EVisibility > InVisibility)
Definition SWidget.cpp:1228
virtual SLATECORE_API bool HasKeyboardFocus() const
Definition SWidget.cpp:959
bool IsEnabled() const
Definition SWidget.h:948
void SetEnabled(TAttribute< bool > InEnabledState)
Definition SWidget.h:942
EVisibility GetVisibility() const
Definition SWidget.h:1009
const FSlateWidgetPersistentState & GetPersistentState() const
Definition SWidget.h:679
Definition Attribute.h:17
const ObjectType & Get() const
Definition Attribute.h:241
bool IsSet() const
Definition Attribute.h:230
static UE_FORCEINLINE_HINT TSharedRef< OtherType, Mode > SharedThis(OtherType *ThisPtr)
Definition SharedPointer.h:1780
Definition SharedPointer.h:692
TSharedRef< ObjectType, Mode > ToSharedRef() const &
Definition SharedPointer.h:1028
UE_FORCEINLINE_HINT const bool IsValid() const
Definition SharedPointer.h:1085
Definition SharedPointer.h:153
Definition SharedPointer.h:1295
Type
Definition SlateEnums.h:291
@ Default
Definition SlateEnums.h:293
Definition TextLayout.h:26
Type
Definition TextLayout.h:28
@ false
Definition radaudio_common.h:23
static INPUTCORE_API const FKey Escape
Definition InputCoreTypes.h:312
static SLATECORE_API const EVisibility HitTestInvisible
Definition Visibility.h:23
static SLATECORE_API const EVisibility Visible
Definition Visibility.h:14
static SLATECORE_API const EVisibility Collapsed
Definition Visibility.h:17
Definition SlateTypes.h:1019
Definition Events.h:51
Definition Geometry.h:40
Definition Events.h:431
Definition InputCoreTypes.h:50
Definition Color.h:48
Definition Margin.h:17
Definition SlateBrush.h:239
Definition SlateColor.h:42
Definition SlateFontInfo.h:147
uint8 bIsInGameLayer
Definition WidgetProxy.h:271
Definition SlateTypes.h:1489
Definition NumericTypeInterface.h:21
Definition NumericTypeInterface.h:50
Definition NumericLimits.h:41
Definition Optional.h:131
constexpr OptionalType & GetValue()
Definition Optional.h:443
constexpr bool IsSet() const
Definition Optional.h:69