KeyEventArgs ?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

kazmii
Just popping in
Just popping in
Posts: 6
Joined: Thu Nov 23, 2006 10:18

KeyEventArgs ?

Postby kazmii » Fri Mar 16, 2007 21:23

hello

I'm using CEGUI with SDL in c++ on linux and and I have little problem
when i try to test key.scancode with CEGUI::key.
I try to make a tab navigation on 3 editbox.

this is my code

Code: Select all


bool Reseau::actionDeplacerTab(const CEGUI::EventArgs& event){
   
    WindowManager& winMgr = WindowManager::getSingleton();

    const WindowEventArgs press = static_cast<const WindowEventArgs&>(event);
    const KeyEventArgs& key = static_cast<const KeyEventArgs&>(event);
   
    //test des attribut de key
    cout<<"- test de la touche tab"<<endl;
    cout<<"key scancode ="<<key.scancode<<endl;
    cout<<"key sysKeys ="<<key.sysKeys<<endl;
    cout<<"key codepoint ="<<key.codepoint<<endl;
   
   
    cout<<"key tab ="<< Key::Tab <<endl;
   

    if(key.scancode == Key::Tab ){
   cout<<"tab test ok"<<endl;
   
   if(press.window == winMgr.getWindow("reseau/serveur/editboxIp")){
        winMgr.getWindow( "reseau/serveur/editboxPort")->activate();
      
   }else if(press.window ==  winMgr.getWindow( "reseau/serveur/editboxPort")){
        winMgr.getWindow( "reseau/serveur/editboxNom")->activate();
      
   }else{
        winMgr.getWindow( "reseau/serveur/editboxIp")->activate();
   }
    }
   
    return true;
}



and this is the output in my prompt when I try tab in the editbox

Code: Select all

- test de la touche tab
key scancode =136745464
key sysKeys =135644992
key codepoint =3084976040
key tab =15


I don't know where is my error because all keys are written well on edibox.
Thank you in advance if somebody could help me.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Mar 16, 2007 21:49

Have you looked at SDL_to_CEGUI_keytable for converting an SDL key and Tab_Order ? I'm using 9 as the codepoint for tab, which is different than the 15 you are getting for Key::Tab.

Scancode probably is keyboard dependant, so using it would be limiting.

kazmii
Just popping in
Just popping in
Posts: 6
Joined: Thu Nov 23, 2006 10:18

Postby kazmii » Sat Mar 17, 2007 19:32

yes i have and i m using the function :

CEGUI::uint BaseCegui::SDLKeyToCEGUIKey(SDLKey key)

i'm using the function like this

Code: Select all

 while (SDL_PollEvent(&e)){
   switch (e.type){
        ...
   case SDL_KEYDOWN:
              System::getSingleton().injectKeyDown(SDLKeyToCEGUIKey(e.key.keysym.sym));
       System::getSingleton ().injectChar (e.key.keysym.unicode & 0xff80 ?
                         e.key.keysym.unicode :
                         e.key.keysym.unicode & 0x007f);
      
       break;
             
   case SDL_KEYUP:
   
       System::getSingleton().injectKeyUp(SDLKeyToCEGUIKey(e.key.keysym.sym));
       break;

         ...
      


I noticed that when I recompile my code, when i try tab in edibox the scancode is different at the end of the number :shock: but all characters I put in editbox are good.

So in wanting to find a best solution I'm using the event with no key test just with editbox event

Code: Select all

   
ebox->subscribeEvent(Editbox::EventTextAccepted, Event::Subscriber(&Reseau::actionDeplacerTab, this));

now the navigation tab run but i have the navigation enter too ^^

I hope my explanation about how I'm using SDLKeyToCEGUIKey, can help you to find my error.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 19 guests