Share via


Handling the Tab Control in AddIn Tools

SharePoint Workspace does not have access to the tab order defined in the form and, therefore, may move the cursor to fields in an unexpected order. To resolve this problem, you can provide an implementation of the ProcessMnemonics method that handles the user tab controls correctly.

To handle the user tab controls correctly, provide the following implementation of the ProcessMnemonics method:

bool ISPWManagedToolAddinUI.ProcessMnemonics(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
{
  Message message = Message.Create(hWnd, msg, wparam, lparam);
  PreProcessControlState state = this.PreProcessControlMessage(ref message);
  if (msg == 0x100 && (int)wparam == 0x09 && state == PreProcessControlState.MessageNotNeeded)
  {
    Control firstControl = GetNextControl(null, true);
    if (firstControl != null)
    {
      firstControl.Select();
      return true;
    }
  }

  return state == PreProcessControlState.MessageProcessed;
}

Alternatively, you can define the ProcessMnemonic method to return false and SharePoint Workspace will handle the user tab controls.

Note

The ProcessMnemonic method was introduced in the April 2012 Office 2010 Cumulative Update. In order for AddIn tools to work correctly, the cumulative update must be applied on the user's system and all AddIns must implement the ProcessMnemonic method.