@@ -50,7 +50,6 @@ static class ValueFactory
5050 internal static bool GetNewValue ( IApplication app , string propertyName , Design design , Type type , object ? oldValue , out object ? newValue , bool allowMultiLine )
5151 {
5252 newValue = null ;
53-
5453 if ( type . IsGenericType && type . GetGenericTypeDefinition ( ) == typeof ( LinearRangeOption < > ) )
5554 {
5655 return RunEditor ( app , new SliderOptionEditor ( app , type . GetGenericArguments ( ) [ 0 ] , oldValue ) , out newValue ) ;
@@ -155,9 +154,9 @@ internal static bool GetNewValue(IApplication app, string propertyName, Design d
155154 }
156155 }
157156 else
158- if ( type . IsEnum )
157+ if ( IsEnumOrNullableEnum ( type , oldValue , out var enumValue ) )
159158 {
160- if ( Modals . GetEnum ( app , propertyName , "New Enum Value" , type , ( Enum ? ) oldValue , out var resultEnum ) )
159+ if ( Modals . GetEnum ( app , propertyName , "New Enum Value" , type , enumValue , out var resultEnum ) )
161160 {
162161 newValue = resultEnum ;
163162 return true ;
@@ -223,6 +222,23 @@ internal static bool GetNewValue(IApplication app, string propertyName, Design d
223222 return false ;
224223 }
225224
225+ private static bool IsEnumOrNullableEnum ( Type type , object ? oldValue , out Enum ? enumValue )
226+ {
227+ if ( type . IsEnum )
228+ {
229+ enumValue = ( Enum ? ) oldValue ;
230+ }
231+
232+ if ( Nullable . GetUnderlyingType ( type ) is Type underlying && underlying . IsEnum )
233+ {
234+ enumValue = ( Enum ? ) oldValue ;
235+ return true ;
236+ }
237+
238+ enumValue = null ;
239+ return false ;
240+ }
241+
226242 private static bool RunEditor < T > ( IApplication app , T editor , out object ? result ) where T : Dialog , IValueGetterDialog
227243 {
228244 app . Run ( editor ) ;
0 commit comments