Hi
I haven't found anything about this in the forum so...
How can I remove the keyinput focus from a window?
I have a console where I do some text input. If I press the middle button of the mouse I'd like the focus to disappear from my console.
Now triggering the mouse is easy but I can't find the method to remove the input focus.
(Btw. the focus doesn't go away either if I just click in an empty place on the screen.)
Any hints are welcome
Regards,
Z
remove keyboard input focus
Moderators: CEGUI MVP, CEGUI Team
remove keyboard input focus
I tried this
But it didn't do what I wanted.
Code: Select all
void removeKeyFocus(){
CEGUI::Window* ceroot=CEGUI::System::getSingleton().getGUISheet();
ceroot->activate();
}
But it didn't do what I wanted.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
remove keyboard input focus
The reason that code does not work is because the active root is always active anyway
The best kludge is to activate a sibling window or a window on a different ancestoral line. If you have no candidate windows, create any window (DefaultGUISheet would be cheapest), set it's size to 0x0, add it to the same parent as your editbox, then activeate it when you need to move focus away from the editbox (it's a bit wanky I know, but it'll work).
I'll add this on the TODO list, as there's currently no way to achieve this via a simple call.
CE.
The best kludge is to activate a sibling window or a window on a different ancestoral line. If you have no candidate windows, create any window (DefaultGUISheet would be cheapest), set it's size to 0x0, add it to the same parent as your editbox, then activeate it when you need to move focus away from the editbox (it's a bit wanky I know, but it'll work).
I'll add this on the TODO list, as there's currently no way to achieve this via a simple call.
CE.
remove keyboard input focus
It works
thank You very much for the fast help
thank You very much for the fast help
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
remove keyboard input focus
I have added a new method to the Window base class 'deactivate' that should now allow you to do this more easily
See the front page about another unrelated change that requires you to update your GUILayout.xsd file from the XMLRefSchema directory.
Allow 5 hrs for anon CVS access to sync (snapshots are current).
HTH
CE.
See the front page about another unrelated change that requires you to update your GUILayout.xsd file from the XMLRefSchema directory.
Allow 5 hrs for anon CVS access to sync (snapshots are current).
HTH
CE.
Re: remove keyboard input focus
Hi,
got a very similiar problem. I want the input focus to be removed by a user clicking anywhere on the canvas. Currently the focus is only removed when the user clicks on another CEGUI widget like a StaticText or a button. My first approach was to create an invisible dummy sheet which was with Window::moveToBack() on a per-frame basis pushed to the bottom of the z-order . Didn't work out because it wasn't somehow incompatible with the rest of widgets (buttons stopped working, etc.), maybe because it's just a minor hack
For better comprehension of my problem, have a look at the following picture.
http://imagebin.org/156624
Thanks for your help in advance,
Chris
got a very similiar problem. I want the input focus to be removed by a user clicking anywhere on the canvas. Currently the focus is only removed when the user clicks on another CEGUI widget like a StaticText or a button. My first approach was to create an invisible dummy sheet which was with Window::moveToBack() on a per-frame basis pushed to the bottom of the z-order . Didn't work out because it wasn't somehow incompatible with the rest of widgets (buttons stopped working, etc.), maybe because it's just a minor hack
For better comprehension of my problem, have a look at the following picture.
http://imagebin.org/156624
Thanks for your help in advance,
Chris
Re: remove keyboard input focus
Hehe, nice thread necromancing.
What is your layout? I think that if you add a DefaultWindow that takes the entire screen and add your widgets to that, the DefaultWIndow will steal keyboard focus once you click on it. I haven't tested it but I recall this working for me, hopefully I am not wrong.
What is your layout? I think that if you add a DefaultWindow that takes the entire screen and add your widgets to that, the DefaultWIndow will steal keyboard focus once you click on it. I haven't tested it but I recall this working for me, hopefully I am not wrong.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: remove keyboard input focus
Kulik wrote:I haven't tested it but I recall this working for me, hopefully I am not wrong.
I have bad news!
The only way to do this reliably at the moment is to subscribe an event handler and use it to deactivate the editbox. So you might for example use the GlobalEventSet with the event "Window/MouseButtonDown", and test if the target window is an editbox, if not find the active editbox and deactivate. It's not all that elegant, but at the moment I think it's the only reliable way.
CE
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: remove keyboard input focus
Kulik wrote:I think that if you add a DefaultWindow that takes the entire screen and add your widgets to that, the DefaultWIndow will steal keyboard focus once you click on it. I haven't tested it but I recall this working for me, hopefully I am not wrong.
Yeap, that's also what I was trying at first. Of course all my windows are children of a "DefaultWindow", so I set the size of my GUI sheet to 100% of the screen to capture all clicks, but as Eddie already said, that isn't working yet.
CrazyEddie wrote:So you might for example use the GlobalEventSet with the event "Window/MouseButtonDown", and test if the target window is an editbox, if not find the active editbox and deactivate.
I gonna feedback whether it works soon. Thanks for the fast replies.
Cryst
Re: remove keyboard input focus
Works fine. Here my code for the following generations.
Registering the global event
Handling the event (in this case focus is only lost when the user left clicks):
Thanks again,
Cryst
Registering the global event
Code: Select all
CEGUI::GlobalEventSet::getSingleton().subscribeEvent(CEGUI::Window::EventNamespace + "/" + CEGUI::Window::EventMouseButtonDown,
CEGUI::Event::Subscriber(&Application::mouseButtonDown, this));
Handling the event (in this case focus is only lost when the user left clicks):
Code: Select all
// "test3d/ChatInput" is my EditBox
bool Application::mouseButtonDown(const CEGUI::EventArgs &e)
{
const CEGUI::MouseEventArgs& mouseeventargs = static_cast<const CEGUI::MouseEventArgs&>(e);
if (mouseeventargs.button == CEGUI::LeftButton &&
mouseeventargs.window != CEGUI::WindowManager::getSingleton().getWindow("test3d/ChatInput"))
CEGUI::WindowManager::getSingleton().getWindow("test3d/ChatInput")->deactivate();
return true;
}
Thanks again,
Cryst
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 4 guests