23
23
import com .badlogic .gdx .scenes .scene2d .ui .SelectBox ;
24
24
import com .badlogic .gdx .scenes .scene2d .ui .Skin ;
25
25
import com .badlogic .gdx .scenes .scene2d .ui .TextField ;
26
+ import com .badlogic .gdx .scenes .scene2d .ui .TextField .TextFieldListener ;
26
27
import com .badlogic .gdx .scenes .scene2d .utils .ChangeListener ;
27
- import com .badlogic .gdx .scenes .scene2d .utils .FocusListener ;
28
28
import com .bladecoder .engine .actions .Action ;
29
29
import com .bladecoder .engine .actions .ActionFactory ;
30
30
import com .bladecoder .engine .actions .Param ;
@@ -73,12 +73,19 @@ public void changed(ChangeEvent event, Actor actor) {
73
73
}
74
74
});
75
75
76
- ((TextField ) classPanel .getField ()).addListener (new FocusListener () {
77
- @ Override
78
- public void keyboardFocusChanged (FocusEvent event , Actor actor , boolean focused ) {
79
- if (!event .isFocused ())
80
- setAction ();
81
- }
76
+ // ((TextField) classPanel.getField()).addListener(new FocusListener() {
77
+ // @Override
78
+ // public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
79
+ // if (!event.isFocused())
80
+ // setAction();
81
+ // }
82
+ // });
83
+
84
+ ((TextField ) classPanel .getField ()).setTextFieldListener (new TextFieldListener () {
85
+ @ Override
86
+ public void keyTyped (TextField textField , char key ) {
87
+ setAction ();
88
+ }
82
89
});
83
90
84
91
if (e != null ) {
@@ -113,8 +120,17 @@ private void setAction() {
113
120
114
121
if (id .equals (CUSTOM_ACTION_STR )) {
115
122
addInputPanel (classPanel );
116
- if (classPanel != null && !classPanel .getText ().trim ().isEmpty ())
123
+ if (classPanel != null && classPanel . getText () != null && !classPanel .getText ().trim ().isEmpty ())
117
124
tmp = ActionFactory .createByClass (classPanel .getText (), null );
125
+
126
+ if (tmp == null ) {
127
+ classPanel .setError (true );
128
+ } else {
129
+ classPanel .setError (false );
130
+ }
131
+
132
+ getStage ().setKeyboardFocus (classPanel .getField ());
133
+
118
134
setInfo (CUSTOM_INFO );
119
135
} else {
120
136
tmp = ActionFactory .create (id , null );
@@ -145,6 +161,8 @@ private void setAction() {
145
161
i [j ].getCell (i [j ].getField ()).fillX ();
146
162
}
147
163
}
164
+ } else {
165
+ i = new InputPanel [0 ];
148
166
}
149
167
150
168
// ((ScrollPane)(getContentTable().getCells().get(1).getActor())).setWidget(getCenterPanel());
@@ -183,11 +201,13 @@ protected void inputsToModel(boolean create) {
183
201
}
184
202
185
203
ActionUtils .setParam (e , i [j ].getTitle (), v );
186
- Ctx . project . setModified ();
204
+
187
205
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e ) {
188
206
EditorLogger .error (e .getMessage ());
189
207
}
190
208
}
209
+
210
+ Ctx .project .setModified ();
191
211
}
192
212
193
213
@ Override
@@ -208,4 +228,17 @@ protected void modelToInputs() {
208
228
}
209
229
}
210
230
}
231
+
232
+ @ Override
233
+ protected boolean validateFields () {
234
+
235
+ String id = actionPanel .getText ();
236
+
237
+ if (id .equals (CUSTOM_ACTION_STR ) && e == null ) {
238
+ if (ActionFactory .createByClass (classPanel .getText (), null ) == null )
239
+ return false ;
240
+ }
241
+
242
+ return super .validateFields ();
243
+ }
211
244
}
0 commit comments