File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
flixel/system/debug/watch Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,9 @@ class EditableTextField extends TextField implements IFlxDestroyable
9393 case TBool :
9494 text = if (text == " true" ) " false" else " true" ;
9595 selectEnd ();
96+ case TEnum (e ):
97+ cycleEnumValue (e , FlxMath .signOf (modifier ));
98+ selectEnd ();
9699 case _ :
97100 setSelection (selection , selection );
98101 }
@@ -114,6 +117,21 @@ class EditableTextField extends TextField implements IFlxDestroyable
114117 text = Std .string (value );
115118 }
116119
120+ private function cycleEnumValue (e : Enum <Dynamic >, modifier : Int ): Void
121+ {
122+ var values = e .getConstructors ();
123+ var index = values .indexOf (text );
124+ if (index == - 1 )
125+ index = 0 ;
126+ else
127+ {
128+ index + = modifier ;
129+ if (index > values .length )
130+ index = 0 ;
131+ }
132+ text = Std .string (values [index ]);
133+ }
134+
117135 private function onFocusLost (_ )
118136 {
119137 setIsEditing (false );
@@ -129,6 +147,9 @@ class EditableTextField extends TextField implements IFlxDestroyable
129147 #end
130148 case TBool if (text == " true" ): true ;
131149 case TBool if (text == " false" ): false ;
150+ case TEnum (e ):
151+ try Type .createEnum (e , text )
152+ catch (_ : Dynamic ) null ;
132153 case _ : text ;
133154 }
134155
You can’t perform that action at this time.
0 commit comments