UI - focus problems

Topics: CAB & Smart Client Software Factory
Nov 8, 2006 at 6:59 AM
originally posted by: pcfountain

Our main application layout consists of a zone workspace, which contains a sort of Outlook-style button bar on the left, displaying various views, and a custom VS2005-style tab control on the right, which also displays views and sometimes a CAB tabbed workspace with other views inside.

The basic problem is: once we start displaying views programmatically, our controls do not gain focus when you click on them. For example, I do a search using a view on the left side. It creates a tab with several views on the right side. Now I click back on my left side control to do another search. It does not have focus - I can see the cursor in my text box, but when I type on my keyboard, the letters don't appear. I have to click on the control a second time before it gains focus. I've tried explicitly setting focus in code with the View's OnEnter event, but then weird things start to happen .. the cursor appears in a different place on the control than where I'm actually typing. Weird stuff.

Anybody know what's going on, or had a similar experience with CAB?
Nov 10, 2006 at 1:05 PM
originally posted by: pcfountain

After a day of research, I've had a mini-breakthrough on this problem. I found a code sample online that calls the Windows API to get the currently focused control, and I set it up to display in the status bar of my app every 1/2 second. What I found out was: on the first click on a control, the underlying Workspace object gains focus. At that point, you can see the cursor flashing in the TextBox/ComboBox/whatever, but if you type on the keyboard nothing happens. Obviously, the keystrokes are being sent to the Workspace and discarded. On the second click on that control, the actual control gains focus and you are ready to type again. This is happening everywhere in our application

I do have a theory .. the main LayoutView of our application is a ZoneWorkspace. Within each zone, we have other views, some of which contain other Workspaces. The problem occurs on any view that is contained in a workspace, which is then contained in one of the zones. (I hope that's not too confusing.)

Does anyone know why a Workspace would "steal" focus from the controls contained in that Workspace? Are there any known issues with nesting workspaces inside the zones of a ZoneWorkspace?
Nov 10, 2006 at 2:33 PM
originally posted by: pcfountain

I just fixed the problem by removing the ZoneWorkspace from the application and just using a plain SplitContainer instead. It was actually quite easy to switch out, and now everything works as it should. This pretty much confirms a bug with the ZoneWorkspace, I'll post that in the bugs forum.