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
Frustrated...need help.
Moderators: CEGUI MVP, CEGUI Team
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
Re: Frustrated...need help.
You would set the focus on a window the activate member function of Window
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:
This is a simple example of what you could do. CEGUI does not currently have any built-in keyboard navigation.
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.
Re: Frustrated...need help.
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
-EDarkness
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Frustrated...need help.
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.
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.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 8 guests