public void Clear() { LogText = "Cleared"; try { RegisterEvent(ValuePattern.ValueProperty); if (ReadOnly) { throw new ProdOperationException("Text Control is Read Only"); } if (ValuePatternHelper.SetValue(UIAElement, "") == 0) { return; } if (NativeWindowHandle != IntPtr.Zero) { NativeTextProds.ClearTextNative(NativeWindowHandle); return; } /* If it doesn't have one, send keys, then */ //TODO: convert ValuePatternHelper.SendKeysSetText(UIAElement, string.Empty); } catch (ProdOperationException err) { throw; } }
private static void UiaClearText(BaseProdControl control) { if (ValuePatternHelper.GetIsReadOnly(control.UIAElement)) { throw new ProdOperationException("Control is Read Only"); } //currently the verification is done in pattern helper ValuePatternHelper.SetValue(control.UIAElement, ""); LogController.ReceiveLogMessage(new LogMessage("Clear Text")); }
public void SetText(string text) { LogText = "Text: " + text; try { RegisterEvent(ValuePattern.ValueProperty); if (ReadOnly) { throw new ProdOperationException("Text Control is Read Only"); } if (ValuePatternHelper.SetValue(UIAElement, text) == 0) { return; } /* If control has a handle, use native method */ if (UIAElement.Current.NativeWindowHandle != 0) { if (NativeTextProds.SetTextNative(NativeWindowHandle, text)) { return; } } /* If it doesn't have one, send keys, then */ //TODO: convert ValuePatternHelper.SendKeysSetText(UIAElement, text); } catch (ProdOperationException err) { throw; } }
/// <summary> /// Set text area value to an empty string /// </summary> /// <param name="controlHandle">NativeWindowHandle to the target control</param> /// <exception cref="ProdOperationException">Examine inner exception</exception> public static void ClearText(IntPtr controlHandle) { if (GetReadOnly(controlHandle)) { throw new ProdOperationException("TextBox is Read Only"); } try { ValuePatternHelper.SetValue(AutomationElement.FromHandle(controlHandle), string.Empty); } catch (InvalidOperationException err) { throw new ProdOperationException(err.Message, err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } }
private static void UiaSetText(BaseProdControl control, string text) { LogController.ReceiveLogMessage(new LogMessage(text)); AutomationEventVerifier.Register(new EventRegistrationMessage(control, ValuePattern.ValueProperty)); ValuePatternHelper.SetValue(control.UIAElement, text); }