EventTextAccepted not working...

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

EventTextAccepted not working...

Postby Derek » Sun May 22, 2005 18:40

Hey,

I've tried to subscribe a WindowsLook/Editbox named "Input" to an EventTextAccepted, but I can't get it to work. injectKeyDown ( ) seems to be returning false when i hit enter.

Code: Select all

 pConsoleInput->subscribeEvent ( Editbox::EventKeyDown, CWindowEventHandlers::HandleConsoleInput );


Where HandleConsoleInput is:

Code: Select all

 bool CWindowEventHandlers::HandleConsoleInput ( const CEGUI::EventArgs &e )


Like I said, it seems that injectKeyDown is just returning false, and HandleConsoleInput is never executed. I've already tried another event (EventTextChanged) and that worked fine. What else am I doing wrong here?

Also, how do you grab a child window? I have a window named console and it has a child named input. I want to get the Console/Input window, but when I try to use WindowManager::getSingleton().getWindow( "Console/Input" ) the library throws an exception and says that the window doesn't exist.

Thanks,

-Derek

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby spannerman » Sun May 22, 2005 22:23

Are you calling injectKeyDown? For example, in OGRE whenever there is a key pressed event I notify CEGUI of the fact, e.g.

Code: Select all

void MyApp::keyPressed(KeyEvent* e)
{
...
  // do event   injection
  CEGUI::System& cegui = CEGUI::System::getSingleton();
  // key down
  cegui.injectKeyDown(e->getKey());
  // now character
  cegui.injectChar(e->getKeyChar());
...
}


Im not sure about your child input problem. Are you sure your passing in the correct string name?
To get for example a textbox I'd do:

Code: Select all

bool MyApp::handleEditBox(const CEGUI::EventArgs& e)
{
  CEGUI::String boxName = (((const CEGUI::WindowEventArgs&)e).window)->getName();
  Editbox* ebox = (Editbox*)WindowManager::getSingleton().getWindow( boxName );

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Sun May 22, 2005 22:55

yes, i'm calling injectKeyDown and Up.


The windows are created through CELayoutEditor.

-Derek

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Mon May 23, 2005 00:13

Oh yeah, doesn't seem like arrow keys/backspace are working either...

I'm just sending the keycode in WPARAM from WM_KEYDOWN straight to injectKeyDown. Is this the right way to do it?

-Derek

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Fri May 27, 2005 18:00

so does anyone know how I can inject keydown/keyups from WM_messages instead of a dinput device without having to edit the cegui sources?

-Derek

User avatar
Nikon
Just popping in
Just popping in
Posts: 10
Joined: Mon Feb 21, 2005 22:42

Re: EventTextAccepted not working...

Postby Nikon » Sat May 28, 2005 01:59

I'm usually just a broswer of this forum and don't usually reply, but here goes nothing...

Code: Select all

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
   {
                case WM_KEYDOWN:
      {
         unsigned char key = wParam;
         System::getSingleton().injectChar(key);

         break;
      }
        }
}


This has worked for me without ever needing to use injectKeyDown, although I think you are probably supposed to.

Hope this works

Nikon

P.S. How's MTA:Blue coming along?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: EventTextAccepted not working...

Postby CrazyEddie » Sat May 28, 2005 09:20

@Derek:
I think the wParam key codes for WM_KEYDOWN are different to the DirectInput key codes, so what you really need is to create a translation lookup table and use that.

Alternatively, you could be very selective about which key up/downs to send (like just shift keys, arrow keys, and return or something) - in which case a simple switch in your WM_KEYDOWN handler would probably suffice.

CE.

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Sat May 28, 2005 16:32

It's coming along rather nicely :)

We just went through a major rewrite of the core part of the project and i'm finishing up a steam-style console.

-Derek

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Sat May 28, 2005 16:40

Thanks eddie, i'll probably just do the latter.

All i REALLY need is enter, arrow keys, page up, page down, home, etc., so I'll just implement those with a switch case.

Thanks guys,

-Derek

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Sat May 28, 2005 18:02

by the way, what is the best thing to use for consoles? I need the text that is echoed to the console to render from the bottom UP, instead of from the top down like it is right now using a multilineeditbox.

-Derek

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: EventTextAccepted not working...

Postby CrazyEddie » Sun May 29, 2005 08:50

Most people use a Listbox for their console output, and make a call to ensure the last line is visible after each output. Though it would still start at the top, so you have a couple of options:

1) Initially pad the output with blank lines, so that the first 'real' line appears at the bottom.

2) Create a customised Listbox for this usage that renders it's items in reverse order.

CE.

User avatar
Derek
Quite a regular
Quite a regular
Posts: 70
Joined: Wed Jan 12, 2005 12:06

Re: EventTextAccepted not working...

Postby Derek » Sun May 29, 2005 17:23

Hmmm... i tried to use a listbox earlier but i couldn't see any text. I'd see the scroll bar get smaller when i added things in, but none of the text would show (adding from a ListboxTextItem).

I would do something like

Code: Select all

pListItem = new ListboxItem ( m_pInputWindow->getText ( ) )
pListBox->addItem ( pListItem );


Anything i'm doing wrong? I'm using the windows look.
InputWindow is an Editbox*.



-Derek

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: EventTextAccepted not working...

Postby lindquist » Sun May 29, 2005 22:51

I think you need to set the text colour. I had that problem myself some time ago...


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests