Frustrated...need help.

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
EDarkness
Just popping in
Just popping in
Posts: 11
Joined: Wed Jul 20, 2005 19:57

Frustrated...need help.

Postby EDarkness » Wed Jul 20, 2005 20:36

Hello. I'm using Ogre and CEGUI. Right now, I'm trying to setup some buttons that will be selectable with the keyboard and when the user presses "enter/return" it will do something. My problem is all of the tutorials assume you're using a mouse. I have mouse functionality turned off, so I need to get it done with a keyboard. Thing is, I can't figure out how to do it. How do you set the focus of the window manually? I want to set one button as the initial focus, then with the up and down arrows the focus moves to the next button. When they hit "enter/return", an event will happen.

Thing is, I have no idea how to set this up. So I've been staring at my code for the last few days not doing anything. I am in serious need of some guidance, otherwise I'm gonna have to drop this. Anyone have any information that can get me in the right direction? Or maybe even some theory I can use to set this up?

Any help would be greatly appreciated.


-EDarkness

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

Re: Frustrated...need help.

Postby lindquist » Wed Jul 20, 2005 22:11

You would set the focus on a window the activate member function of Window

Code: Select all

Window* w = WindowManager::getSingleton().getWindow("myWindow");
w->activate();


this would ensure that keyboard events would be sent to "myWindow"

if you pressed "down-arrow" with this window active, a "KeyDown" event would be sent to it.

a handler like this could pass on the focus:

Code: Select all

bool myWindowKeyDownHandler(const EventArgs& e)
{
    const KeyEventArgs& ke = (const KeyEventArgs&)e;
    if (ke.scancode == Key::ArrowDown)
    {
        Window* next = WindowManager::getSingleton().getWindow("myNextWindow");
        next->activate();
        return true;
    }
    return false;
}


This is a simple example of what you could do. CEGUI does not currently have any built-in keyboard navigation.

User avatar
EDarkness
Just popping in
Just popping in
Posts: 11
Joined: Wed Jul 20, 2005 19:57

Re: Frustrated...need help.

Postby EDarkness » Wed Jul 20, 2005 23:29

Well, that's good to hear. How do you know if the window has focus? Does it light up like it would if you moused over it? Oh, and how to I "fake" mouse events?


-EDarkness

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

Re: Frustrated...need help.

Postby CrazyEddie » Fri Jul 22, 2005 11:33

For the most part there is no visual cue that a widget has input focus. However, buttons have a hover highlight.

What you basically want to do, is respond to the keyboard and move the 'invisible' mouse to the next widget by injecting an appropriate mouse position - by doing this over a series of buttons for example, each button would highlight in turn.

Chris Kang started the work on implementing a proper keyboard interface (there's a patch on the tracker), however I had trouble getting it to function (could have been me though), and Chris has not posted here for a few months.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 9 guests