SIL.FieldWorks.XWorks.FwXWindow.FocusControlHandlesMessage C# (CSharp) Method

FocusControlHandlesMessage() private method

See whether the focus control wants to handle the specified message. It is assumed that if the focus control has a public or non-public method of the given name, it takes the supplied arguments and returns boolean. Call it and return what it returns. Special case: if the focus control is 'this', that is, the recipient xWindow has focus, just return false. This is because this method is called from, say, the implementation of OnDisplayUndo, to see whether some (other) focus control wants to handle the message. Returning false allows the correct default implementation of OnDisplayUndo when no (other) focused control wants to do it. Calling OnDisplayUndo on the focus control, on the other hand, leads to a stack overflow, since the first thing this.OnDisplayUndo does is to call FocusControlHandlesMessage again!
private FocusControlHandlesMessage ( string methodName, object args ) : bool
methodName string
args object
return bool
		private bool FocusControlHandlesMessage(string methodName, object[] args)
		{
			// See whether the control that has focus wants to process this message.
			// Normally we would try to arrange that this control comes before the main window
			// in the list of message targets, but the FwXWindow is before the clerk which
			// says it has to be before the content control in the master list of targets.

			// first, try to use a control that has 'registered' to be first control to handle messages.
			// this provides certain controls the opportunity to still try to handle messages even if
			// they are not precisely in Focus. (see LT-7791)
			Control focusControl = GetFocusControl();
			if (focusControl != null && focusControl != this)
			{
				MethodInfo mi = focusControl.GetType().GetMethod(methodName,
					BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
				if (mi != null)
					return (bool)mi.Invoke(focusControl, args);
			}
			return false;
		}
FwXWindow