MCPcopy Create free account
hub / github.com/Card-Forge/forge / startEdit

Method startEdit

forge-gui-mobile/src/forge/toolbox/FTextField.java:235–352  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233 }
234
235 public boolean startEdit() {
236 if (readOnly) { return false; }
237 Forge.setOnScreenKeyboard(true, isNumeric);
238 if (isEditing) { return true; } //do nothing if already editing
239
240 selStart = 0; //select all before starting input
241 selLength = text.length();
242 textBeforeKeyInput = text; //backup text before input to detect changes
243
244 Forge.startKeyInput(new KeyInputAdapter() {
245 @Override
246 public FDisplayObject getOwner() {
247 return FTextField.this;
248 }
249
250 @Override
251 public boolean allowTouchInput() {
252 return true;
253 }
254
255 @Override
256 public boolean keyTyped(char ch) {
257 insertText(String.valueOf(ch));
258 return true;
259 }
260
261 @Override
262 public boolean keyDown(int keyCode) {
263 switch (keyCode) {
264 case Keys.TAB:
265 case Keys.ENTER: //end key input on Tab or Enter
266 Forge.endKeyInput();
267 return true;
268 case Keys.ESCAPE:
269 setText(textBeforeKeyInput); //cancel edit on Escape
270 Forge.endKeyInput();
271 return true;
272 case Keys.BACKSPACE: //also handles Delete since those are processed the same by libgdx
273 if (text.length() > 0) {
274 if (selLength == 0) { //delete previous or next character if selection empty
275 if (selStart > 0) {
276 selStart--;
277 }
278 selLength = 1;
279 }
280 insertText("");
281 }
282 return true;
283 case Keys.LEFT:
284 if (selLength == 0) {
285 if (selStart > 0) {
286 selStart--;
287 }
288 }
289 else {
290 selLength = 0;
291 }
292 return true;

Callers 3

tapMethod · 0.95
keyDownMethod · 0.95
showInputDialogMethod · 0.95

Calls 3

setOnScreenKeyboardMethod · 0.95
startKeyInputMethod · 0.95
lengthMethod · 0.80

Tested by

no test coverage detected