hey all,
I've implemented an IE toolbar, hooking up the TranslateAcceleratorIO, HasFocusIO and UIActivateIO methods of the IInputObject interface. Tabbing between my toolbar and the rest of the IE interface works great... but only after you've tabbed in to the toolbar for the first time?
What I've noticed is that the expected calls to HasFocusIO and UIActivateIO simply aren't firing when you click into the toolbar, despite calls off to OnFocusChangeIS when the toolbar or any child windows get and lose the focus.
To give you an idea of the code I'm using...
// fired when any child control or this control gets the focus
private void OnContainsFocus()
{
Debug.WriteLine("GotFocus " + this.ActiveControl.Name);
BandObjectSite.OnFocusChangeIS(this as Interop.IInputObject, Interop.NativeConstants.S_OK);
}
// fired when any child control or this control loses the focus
private void OnLostFocus()
{
//if (ActiveControl == null)
BandObjectSite.OnFocusChangeIS(this as Interop.IInputObject, Interop.NativeConstants.S_FALSE);
Debug.WriteLine("LostFocus " + this.ActiveControl.Name);
}
public virtual Int32 HasFocusIO()
{
Debug.WriteLine("HasFocusIO" + ContainsFocus + "(" + ActiveControl.Name + ")");
return this.ContainsFocus ? Interop.NativeConstants.S_OK : Interop.NativeConstants.S_FALSE;
}
public virtual void UIActivateIO(Int32 fActivate, ref Interop.MSG Msg)
{
Debug.WriteLine("UIActivateIO" + fActivate + "(" + this.ActiveControl + ")");
if( fActivate != 0 )
{
// extra logic to focus correct control removed for brevity
// take the focus, as requested
this.Focus();
}
}
Clicking in and out of the toolbar only ever fires GotFocus and LostFocus... and you don't get the expected call to HasFocusIO until an entire round of tabbing (ie tabbing through every control and coming back to the toolbar for a second time). After that everything behaves exactly as I'd expect.
I realise it's hard to visualize here - but any brainwaves would be much appreciated!