357 |
}} |
}} |
358 |
} |
} |
359 |
|
|
|
|
|
|
public void handleKeyStroke(String stroke, AbstractMainNode2D main) |
|
|
{ try { |
|
|
// synchronized(fen) XXX |
|
|
if(dbg) p("s: "+stroke+", v: "+main); |
|
|
|
|
|
if (stroke.equals("Return")) { |
|
|
if(dbg) p("Insert \\n"); |
|
|
if (accursed[CURR]==null) return; |
|
|
|
|
|
String acc = Nodes.toString(accursed[CURR]); |
|
|
ppAct.insertText(acc, cursorOffset[CURR], "\n"); |
|
|
cursorOffset[CURR]++; |
|
|
} |
|
|
else if (stroke.equals("Backspace")) { |
|
|
if (accursed[CURR]==null) return; |
|
|
|
|
|
String note = Nodes.toString(accursed[CURR]); |
|
|
if (cursorOffset[CURR] >= 1) { |
|
|
ppAct.deleteText(note, |
|
|
cursorOffset[CURR] - 1, |
|
|
cursorOffset[CURR]); |
|
|
cursorOffset[CURR]--; |
|
|
String text = alphContent.getText(fen.constgraph, |
|
|
accursed[CURR]); |
|
|
if (cursorOffset[CURR] == 0 && |
|
|
text.length() == 0) { |
|
|
if (isLinked(accursed[CURR])){ |
|
|
ppAct.insertText(note, 0, "#"); |
|
|
} else { |
|
|
ppAct.deleteNote(note); |
|
|
accursed[CURR] = null; |
|
|
cursorOffset[CURR] = -1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if (stroke.equals("Left")) { |
|
|
if (accursed[CURR]==null) return; |
|
|
if (cursorOffset[CURR] > 0) cursorOffset[CURR]--; |
|
|
} |
|
|
else if (stroke.equals("Right")) { |
|
|
if (accursed[CURR]==null) return; |
|
|
String text = alphContent.getText(fen.constgraph, accursed[CURR]); |
|
|
if ( cursorOffset[CURR] < text.length()) |
|
|
cursorOffset[CURR]++; |
|
|
} |
|
|
// normal alphabets etc. |
|
|
else if (stroke.length() == 1) { |
|
|
char c = stroke.toCharArray()[0]; |
|
|
p("Pressed: '"+ stroke +"', ch: '"+c+"' and int: "+ (int)c); |
|
360 |
|
|
361 |
if (accursed[CURR]==null) { |
public void handleKeyStroke(String s, AbstractMainNode2D main) { |
362 |
String paper = Nodes.toString(main.getPlane()); |
throw new Error("method removed"); |
|
String note = ppAct.newNote(paper, (int)main.getFocus().getPanX(), |
|
|
(int)main.getFocus().getPanY(), ""); |
|
|
cursorOffset[CURR] = 0; |
|
|
accursed[CURR] = Nodes.get(note); |
|
|
} |
|
|
String acc = Nodes.toString(accursed[CURR]); |
|
|
ppAct.insertText(acc, cursorOffset[CURR], stroke); |
|
|
cursorOffset[CURR]++; |
|
|
return; |
|
|
} else p("No keystroke defined!"); |
|
|
} catch (RemoteException e) { |
|
|
p("RemoteException ocurred! "+e); |
|
|
return; |
|
|
}} |
|
|
|
|
|
private boolean isLinked(Object node) { |
|
|
Object test = fen.graph.find1_11X(node, STRUCTLINK.linkedTo); |
|
|
if (test != null) return true; |
|
|
test = fen.graph.find1_X11(STRUCTLINK.linkedTo, node); |
|
|
if (test != null) return true; |
|
|
return false; |
|
363 |
} |
} |
364 |
|
|
365 |
} |
} |