Can can I transfer the irr message?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
rabbitygm
Posts: 6
Joined: Sat Apr 04, 2009 3:34 pm

Can can I transfer the irr message?

Post by rabbitygm »

Hi~~I'm newer of learning irr engine.
now I hava a problem.When I open a UI window and I input the editbox,but at the same time my scene node that proccess the input message work too .How can I prevent the message transfer to the scene node ?Actually,I just want to edit the box but not the scene no ....
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Could you show some code, maybe this makes your question a little more comprehensible.
rabbitygm
Posts: 6
Joined: Sat Apr 04, 2009 3:34 pm

Post by rabbitygm »

I control a player node by the keyboard.' W','S','A','D' will contrlol the behavior of it.
At the same time,I load a UI by
gEnv->loadGUI("media\\xml\\window_menu_personal_inf.xml");
there will be present a window.And the window contain a editbox.
When I press key ' W','S','A','D' in the editbox,how can I prevent the player from walking ?

thanks ...
[/img]
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You have to code it. There are several way to do that, but first step is to recognize that you have two different states. One for input (or maybe even a gui-state) and one for controlling your character. So you have to code some some method to find out in which state you are. If you only want to know if the input-field is currently active you can do that by checking if it has the focus. But there might be other way - for example I am using a chat-class which knows itself if it is currenlty active and it does so by checking if it's gui is visible.

Once you know in which state you are you have again several ways to continue. You can remove or disable the input-receiving code for steering code for a while (I usually do that). Or you can ignore the input code in the movement for that time.

But there's no automatism for that - you have to code it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rabbitygm
Posts: 6
Joined: Sat Apr 04, 2009 3:34 pm

Post by rabbitygm »

thanks CuteAlien....
I just feel the message go throught the GUI and scene,i can't stop it.
how can i remove or disable the input-receiving?could you show some code?
I really have no idea about it.....
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Well, I don't know how you currently control your character. If you do it through the camera then I think you can just set camera->setInputReceiverEnabled(false) while the editbox has the focus. Otherwise you have to tell what you currently do.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rabbitygm
Posts: 6
Joined: Sat Apr 04, 2009 3:34 pm

Post by rabbitygm »

I create a 3rd personal camera,i just control a character throught keyboard.
e.g 'w' meaning forword.
i afaid the method camera->setInputReceiverEnabled(false) did't suit it....
is there any more method exist for me to disable the the input?

here is the code....I create a custom animator to proccess input.and then just character ->addAnimator....
in fact,i just want to focus the editbox...I dont't want my character corresponding the key ' W', 'S', 'A', 'D'....


bool CSceneNodeAnimatorPlayer::OnEvent( const SEvent& event )
{

// ----------------------------------------------------
if ( mbFreeModeOpen && event.EventType == EET_KEY_INPUT_EVENT)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
{
mbKeyDowned_W = event.KeyInput.PressedDown;
break;
}
case KEY_KEY_S:
{
mbKeyDowned_S = event.KeyInput.PressedDown;
break;
}
case KEY_KEY_A:
{
mbKeyDowned_A = event.KeyInput.PressedDown;
break;
}
case KEY_KEY_D:
{
mbKeyDowned_D = event.KeyInput.PressedDown;
break;
}
default:
{
return false;
}
}

mbFreeMoving = mbKeyDowned_W || mbKeyDowned_S || mbKeyDowned_A || mbKeyDowned_D;

if(mbFreeMoving)
{
mbAutoMoving = false;

if( mpArrow )
{
mpArrow->setVisible(0);
}
}

return false;
}
}


thanks you....
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Well, that line

Code: Select all

if ( mbFreeModeOpen && event.EventType == EET_KEY_INPUT_EVENT) 
looks to me like you could add another check there. Make sure you have acces to the guienvironment and your editboxpointer and then you can do something like:

Code: Select all

if ( mbFreeModeOpen && event.EventType == EET_KEY_INPUT_EVENT
&& !guiEnv->hasFocus(myEditBox)
) 
Then that code won't run anymore if the corresponding editbox has the focus and you don't move your character anymore.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rabbitygm
Posts: 6
Joined: Sat Apr 04, 2009 3:34 pm

Post by rabbitygm »

CuteAlien,thanks for your code.
Yes ,you're right,you lend me a great help....
I'm stupid , thanks....
Post Reply