JMEDesktop only after event


I’m trying to implement JMEDesktop into my project and have some questions to you.

I reduced the code of the TestJMEDesktop so that I have only the button and the cursor. This code I’ve implemented into my code. When I call the desktop at program start in the simpleInitGame() the desktop with the button and the mousecursor is show, but when I call the desktop after I’ve pressed on my mediaplayer (it should appear only when I press this player) the screen turns black and the cursor is also weird.

Here are some screenshots of this problem:

before call:

after call: … this white thing should be the cursor

Initialize the desktop at startup and cull it (CULL_ALWAYS). After the in-game button is pressed show the desktop (CULL_DYNAMIC). This should work smoothly.

Hi irrisor,

thanks a lot for your reply. I change the code and now the desktop appears after I pressed the player. But somehow the input listener for the button doesn't work anymore… I put these code lines from the desktop method to the player button:

desktopNode.setCullMode( SceneElement.CULL_DYNAMIC );

input = new InputHandler();

lookHandler = new KeyboardLookHandler( cam, 50, 1 );

input.addToAttachedHandlers( lookHandler );

cursor.registerWithInputHandler( input );

When I don't do this I cannot move through the room rather I can only move back, forth, left and right…but not turn arround so that I cannot reach the button on my player. When I put these lines to the code segment which is called when I press the player button, I can move like I want… but… when the desktop appears with its button I can move with the mouse cursor to it, but when I click on it nothing happens. Somehow the listener won't work.

this is the code with the lines I commented out:

      private void createDesktop(){

         //input = new InputHandler();


  1. Don't create a new input handler when showing the desktop - create it where you did before and disable the input for the desktop. When showing it just change the cull mode and enable the input.
  2. To close it set the cull mode to always again and disable the input handler.

ok, thanks…now I can move and click on the appearing button. The closing of the desktop works also very well. But now the problem is, that when I move the mouse cursor to the button I move also the cam in the background. Is it possible to freeze the cam, so that I move only the cursor and not the cam?

yes, like shown in TestJMEDesktop you can disable the 'normal' input handler. Maybe you need to separate it from the global one first.

Glad it works.

Having multiple input handlers is 'normal', yes :slight_smile: - they can be cascaded, also

Yeah…finally it works. I checked the attached InputHandlers…is it usual that there are two handlers (one for mouse and one for keyboard) except my firstpersonhandler and the handler from the desktop? I had to disable them in the simpleInitGame(); first. I find them out with input.getFromAttachedHandlers(index)…0 and 1 …i had to diasable…without that it doesn't work.


when I type in letters, for example to call someone in my Skype contact list, the "special keys" like 't' , 'b' or 'n' are changing the displayed content. Can you tell me how to avoid this?

yes, disable the input handler where these actions are registered - it's the one in SimpleGame (AbstractGame, StandardGame) or whatever you are using.

Hi, do you mean this?



These are the input handlers I've disabled in my simpleInitGame(). I'm not sure if I know what you mean, sorry.Now I have the fp-handler (it's input index no. 2) to move my cam and the other handler (it's input index no. 3) to move the mouse in the desktop. :?

btw. Do you know an example or tutorial for a radio button listener? in TestJMEDesktop it's only shown how to create them.

It is 'input' itself. This is somewhat inconvenient as you'd need to have other input handlers somewhere else if you disable the default 'input'. :expressionless: So you need to remove the attachment of the desktop input handler and update it yourself (e.g. inputForDesktop.update(tpf); in the simpleUpdate method).

Have a look into the JavaDoc for the JRadioButton. It has several events you need to decide what should be listened to.

Hi, I've got my radio buttons working  :D.

To  disable the functions of 't', 'b' … I looked into the and I commented out the actions for these keys. But I think this way is not the best. Can I change them in my program with something like "input. …"? I have no idea which methods are right.

You can add these lines to be beginning of your simpleInitGame method:

        InputHandler handlerForDefaultKeyActions = input;
        input = new InputHandler();
        input.addToAttachedHandlers( handlerForDefaultKeyActions );

You can then disable the keys with

handlerForDefaultKeyActions.setEnabled( false );

I tried it, but it doesn't work. With these code lines I cannot move with mouse or keyboard and it has no effect on the special keys.

Ah, yes, you need to create your own first person handler with that removeAllFromAttachedHandlers - or comment out that line.

And you are right, it does not affect the keys you mentioned :frowning: - they are still handled with isValidCommand which does not use the InputHandlers. You can't switch off these command easily, sorry. You can alter BaseSimpleGame or create an own Game subclass, though.

Thanks, I will leave the comments in the

I've tried it as well, and the following code did remove all of the keybindings allocated by simple game:

      KeyBindingManager kbd = KeyBindingManager.getKeyBindingManager();
      // kbd.remove("exit")

This worked like a charm.