Move focus to another Bar

Bars for Windows Forms Forum

The latest build of this product (v21.1.1) was released 16 days ago, which was before this thread was created.
Posted 14 days ago by AF
Version: 21.1.1
Avatar

I have 2 toolbars, each has a BarComboBox.

When one combobox has focus and the user presses 'Tab' I want the focus to change to the combobox on the 2nd toolbar.

I have this working by deriving a class from BarComboBoxLink and storing a reference to the other combobox (in my example this is named NextCommandLink):

protected override ActiproSoftware.ComponentModel.DefaultableBoolean ProcessKeyDown(Keys key)
{
    if (key == Keys.Tab)
    {
        if (this.NextCommandLink != null && this.NextCommandLink.Control.Visible)
        {
            this.NextCommandLink.BarControl.SelectedCommandLink = this.NextCommandLink;
            this.NextCommandLink.Control.Focus();
            return ActiproSoftware.ComponentModel.DefaultableBoolean.True;
        }
    }

    ...
}

This sort of works, but the other controls on the newly active toolbar don't respond correctly as if the toolbar state has not correctly been updated to be focussed and enabled (where as if I just click in the combobox on the 2nd toolbar using the mouse they work as expected).

Is there a better way to do this?

Comments (1)

Posted 13 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Without having a sample to debug against, my best guess is that changing focus before the "key down" event has finished processing may not allow the focus change to complete. You could try delaying execution of the "Control.Focus()" call to allow "key down" processing to complete first. Something like:

this.NextCommandLink.Control.BeginInvoke(() => this.NextCommandLink.Control.Focus());

If that doesn't work, could you please put together a sample application that demonstrates the issue and send to our support email so we can see if any internal code changes are needed? Please reference this forum post in the support email and be sure not to include the "bin" or "obj" folders when zipping the sample or the attachment might be blocked.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.