Lemur: navigate words in text field, blocked by listener?

I am trying to navigate words on the input text field with ctrl+right ctrl+left.
But these key combinations seems to be dropped, they cant reach my code at:

new KeyActionListener(){public void keyAction(TextEntryComponent source, KeyAction key) {...

What can I do?

Hmmm… not sure why they would be blocked. Are you able to successfully register other key action listeners?

I can’t see how the listener is registered so it’s hard for me to comment beyond just the little view I have.


aaaarrrrgg, I left my dumb mode on again lol…

getInputField().getActionMap().put(new KeyAction(KeyInput.KEY_LEFT,KeyAction.CONTROL_DOWN), actSimpleActions);
getInputField().getActionMap().put(new KeyAction(KeyInput.KEY_RIGHT,KeyAction.CONTROL_DOWN), actSimpleActions);

this topic is useless, feel free to delete is as I cant seem to do it sorry :slight_smile:

I’ll leave it as it might help someone else that needs to do the same thing… plus it shows that people really do use Lemur. :slight_smile:

1 Like

@pspeed ok cool!

btw, still on this subject,
to position the carat properly I am having to use a trick:

	DocumentModel dm = textfield.getDocumentModel();
	for(int i=0;i<iMoveCaratTo;i++){
       // this other trick resets the cursor position visually

as I cant find a way to call textfield.text[TextEntryComponent].resetCursorPosition() directly

any tip to avoid using this trick?

EDIT: I use this after a paste text insert in the middle region of the textfield string

I think it’s some missing functionality from DocumentModel… on two counts:

  1. inserting text should probably automatically move the carat.
  2. there should be a way to manually set the carat index. If one can get it then one should be able to set it, after all.

And the other I think is a bug.

Not sure when I can get to a fix for any of it… so your work-around may have to stand for a while unless you get really fed up with it and submit a patch. :slight_smile:

1 Like


Is working fine now, I did this:

	DocumentModel dm = tf.getDocumentModel();
	for(int i=0;i<str.length();i++)dm.insert(str.charAt(i));

and it modified the TextField text in memory.

But I still had to use the trick as it would not update the visible text until I did this:


that called TextEntryComponent.resetCursorPosition();

I think this “patch”:

TextField.insertText(String str){

TextEntryComponent.insertText(String str){
  for(int i=0;i<str.length();i++)model.insert(str.charAt(i));

would avoid the trick?

finally I got to it…

added insert text capability to TextField and TextEntryComponent, wit… · AquariusPower/Lemur@972385c · GitHub

EDIT: working! below I keep just for reference, I just had to add the file named lemur.build.date with the content ex.: 20161204

EDIT: ugh… below seems related to build.xml, I think I can do it by hand without netbeans…

it compiles, but I am having a problem (at Eclipse), I am not being able to actually test it:

java.lang.IllegalArgumentException: resource lemur.build.date not found.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:119)
at com.google.common.io.Resources.getResource(Resources.java:157)
at com.simsilica.lemur.GuiGlobals.logBuildInfo(GuiGlobals.java:194)
at com.simsilica.lemur.GuiGlobals.setInstance(GuiGlobals.java:125)
at com.simsilica.lemur.GuiGlobals.initialize(GuiGlobals.java:119)
at com.simsilica.lemur.demo.BasicDemo.simpleInitApp(BasicDemo.java:97)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
at java.lang.Thread.run(Thread.java:745)

even after I have added the resources properly:

<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>

I tried to look for such reference stored somewhere, even on the Lemur jar release, but I couldnt understand what dependency is that?

build.xml is not really supported anymore. Lemur is built with gradle now and will generate that file during compile.

You shouldn’t have to reset the cursor position since the insert() should automatically do that now.

1 Like

And by the way for those following along at home, on both fronts, I did the insertText() a different way:

And made the error for lack of build.date less catastrophic: