Textfield: Copy/Paste/Ctrl+X not working

Hey,
i’ve had troubles with the copy paste functionality.

So i saw the following line commented out in Screen.java:

[java]
@Override
public void setClipboardText(String text) {

// clipboard.setContents(stringSelection, this);

}
[/java]

I guess that is WIP so i’m just using the (placeholder?) variable clipboardText of Screen:
[java]
@Override
public void setClipboardText(String text) {
this.clipboardText = text;
}

[/java]

Works for the moment.

Another issue was CTRL+X and CTRL+A not working … as it is not yet implemented. Suggestion as follows in TextField.java:
[java]
@Override
public void onKeyPress(KeyInputEvent evt)
{

if (ctrl)
{
if (evt.getKeyCode() == KeyInput.KEY_C)
{
if (copy)
screen.setClipboardText(textRangeText);
}
else if (evt.getKeyCode() == KeyInput.KEY_V)
{
if (paste)
this.pasteTextInto();
}
else if (evt.getKeyCode() == KeyInput.KEY_A)
{
selectTextRangeAll();
}
else if (evt.getKeyCode() == KeyInput.KEY_X)
{
if (copy)
{
screen.setClipboardText(textRangeText);
this.setText("");
}
}
}

}
[/java]


Yep. :slight_smile:

I believe this is because the commented out clipboard code relies on java.awt.Clipboard, but tonegodgui supports Android as well which uses a different interface (and doesn’t have AWT afaik). Some kind of abstraction is going to be needed.

@rockfire said: I believe this is because the commented out clipboard code relies on java.awt.Clipboard, but tonegodgui supports Android as well which uses a different interface (and doesn't have AWT afaik). Some kind of abstraction is going to be needed.

Exactly… and so far, it has alluded me (mostly because of lack of trying) Though, I have quite a few test devices for Android now and might be able to get this working again.

I’m guessing an interface and some smart loading would do the trick.

@h1ghst0r3y
I’ll start looking into getting this working again soon.

I wondered if LWJGL has clipboard support. It would be a fairly logical place to have it. But … it seems it only has HALF of what you need, Sys.getClipboard() :frowning: