Focus between two wxFrame ? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Muetdhiver
Super wx Problem Solver
Super wx Problem Solver
Posts: 323
Joined: Sun Jun 08, 2008 11:59 am
Location: Bordeaux, France

Focus between two wxFrame ?

Post by Muetdhiver » Fri Oct 07, 2011 9:10 am

Hi,
I again have a focus problem !!!

Simple explanation of I want to do :
I've got 2 wxFrame :
- My main application, that has a lots of controls
- A frame that display logs (messages, errors, etc...) in the bottom of my screen. This frame only shows when a new message is displayed, stays displayed 5 seconds, and then it is closed.

In my main application, let's take this example : I've got a text control that doesn't accept all letter (for example, "&" is forbidden). In this case, it raises a message error, and the log window appears !
The product effect is that the log window is now focused for 5 seconds. When it closes, the focus come back on the main application, in my text control.

Want I want to achieve :
When the log shows, to display errors, the focus remains on the main application, in the text control I was writing in....

Is there a way of doing this ?
That is to say : the log window only shows, but never receive the focus ?
Or should I do it manually, that is to say, when the main frame losts the focus, save the previous object the has this focus, and when the message is written in the log panel, set back the focus to the main frame that broadcasts it to the inner object that was previously saved, etc..... that is really complicated because I have several nested panels in a notebook, and a lots of controls into......

Here is a screenshot that tells :
Image

So, when "Letter not accepted" is written, I want the focus quickly comes back to where it was, before waiting 5 seconds the log windows closes.

Do you have an idea ?
Thanks a lot.
OS: Ubuntu 11.10
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3

User avatar
doublemax
Moderator
Moderator
Posts: 15507
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Focus between two wxFrame ?

Post by doublemax » Fri Oct 07, 2011 10:54 am

From a GUI point of view i don't like the solution with a separate log frame very much. I'd display the error message in the status text or in a separate wxStaticText that's usually empty or hidden.

Also, when you're using wx 2.9.x, take a look at wxInfoBar and wxNotificationMessage.
http://docs.wxwidgets.org/trunk/classwx_info_bar.html
http://docs.wxwidgets.org/trunk/classwx ... ssage.html

You can see examples for these in the "dialogs" sample.
Use the source, Luke!

Muetdhiver
Super wx Problem Solver
Super wx Problem Solver
Posts: 323
Joined: Sun Jun 08, 2008 11:59 am
Location: Bordeaux, France

Re: Focus between two wxFrame ?

Post by Muetdhiver » Fri Oct 07, 2011 1:28 pm

Hi !

Thanks for your answer.
But all my design is based on this, for now I've not planned to change this (I always remove MDI windows.... it was a very big work !!).

So, I finally found the solution after hours of tries, I just called Raise() function on the log frame parent (my main application). So, at every log, the main frame stays first in Z-order and always have the focus.

I think all my focus problems are over !

Again thanks for the help.

Bye.
OS: Ubuntu 11.10
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3

Post Reply