private protected override void OnClick() { var hasAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.InvokePatternOnInvoked); if (hasAutomationListener) { var automationPeer = GetOrCreateAutomationPeer(); if (automationPeer != null) { automationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } } base.OnClick(); }
private protected override void OnLoaded() { base.OnLoaded(); var spCurrentFocusedElement = this.GetFocusedElement(); var focusManager = VisualTree.GetFocusManagerForElement(this); bool setDefaultFocus = focusManager?.IsPluginFocused() == true; if (setDefaultFocus && spCurrentFocusedElement == null) { // Set the focus on the first focusable control var spFirstFocusableElementCDO = focusManager?.GetFirstFocusableElement(this); if (spFirstFocusableElementCDO != null && focusManager != null) { var spFirstFocusableElementDO = spFirstFocusableElementCDO; focusManager.InitialFocus = true; try { var focusUpdated = this.SetFocusedElement( spFirstFocusableElementDO, FocusState.Programmatic, false /*animateIfBringIntoView*/); } catch (Exception ex) { if (this.Log().IsEnabled(LogLevel.Error)) { this.Log().LogError($"Setting initial page focus failed: {ex}"); } } } if (spFirstFocusableElementCDO == null) { // Narrator listens for focus changed events to determine when the UI Automation tree needs refreshed. If we don't set default focus (on Phone) or if we fail to find a focusable element, // we will need notify the narror of the UIA tree change when page is loaded. var bAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.AutomationFocusChanged); if (bAutomationListener) { Uno.UI.Xaml.Core.CoreServices.Instance.UIARaiseFocusChangedEventOnUIAWindow(this); } } } }
internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args) { bool hasAutomationListener = false; base.OnPropertyChanged2(args); if (args.Property == ToggleSwitch.IsOnProperty) { OnToggled(); hasAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.PropertyChanged); if (hasAutomationListener) { var spAutomationPeer = GetOrCreateAutomationPeer(); if (spAutomationPeer != null) { if (spAutomationPeer is ToggleSwitchAutomationPeer spToggleSwitchAutomationPeer) { spToggleSwitchAutomationPeer.RaiseToggleStatePropertyChangedEvent(args.OldValue, args.NewValue); } } } } else if (args.Property == HeaderProperty) { UpdateHeaderPresenterVisibility(); OnHeaderChanged(args.OldValue, args.NewValue); } else if (args.Property == HeaderTemplateProperty) { UpdateHeaderPresenterVisibility(); } else if (args.Property == OffContentProperty) { OnOffContentChanged(args.OldValue, args.NewValue); } else if (args.Property == OnContentProperty) { OnOnContentChanged(args.OldValue, args.NewValue); } else if (args.Property == VisibilityProperty) { OnVisibilityChanged(); } }
/// <summary> /// Raises the Click routed event. /// </summary> private protected override void OnClick() { var hasAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.InvokePatternOnInvoked); if (hasAutomationListener) { var automationPeer = GetOrCreateAutomationPeer(); if (automationPeer != null) { automationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } } base.OnClick(); // If this button has associated Flyout, open it now. OpenAssociatedFlyout(); }
internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args) { base.OnPropertyChanged2(args); if (args.Property == IsCheckedProperty) { OnIsCheckedChanged(); var hasAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.PropertyChanged); if (hasAutomationListener) { var automationPeer = GetOrCreateAutomationPeer(); if (automationPeer != null && !(this is RadioButton)) { (automationPeer as ToggleButtonAutomationPeer)?.RaiseToggleStatePropertyChangedEvent(args.OldValue, args.NewValue); } } } }
private protected override async void OnClick() { var hasAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.InvokePatternOnInvoked); if (hasAutomationListener) { var automationPeer = GetOrCreateAutomationPeer(); if (automationPeer != null) { automationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } } base.OnClick(); // If NavigateUri is set, launch it in external app. var uri = NavigateUri; if (uri != null) { await Launcher.LaunchUriAsync(uri); } }
internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args) { base.OnPropertyChanged2(args); if (args.Property == GroupNameProperty) { OnGroupNamePropertyChanged(args.OldValue, args.NewValue); } else if (args.Property == IsCheckedProperty) { AutomationPeer?automationPeer = null; bool bOldValue = false; bool bNewValue = false; var bListenerExistsForPropertyChangedEvent = AutomationPeer.ListenerExistsHelper(AutomationEvents.PropertyChanged); var bListenerExistsForElementSelectedEvent = AutomationPeer.ListenerExistsHelper(AutomationEvents.SelectionItemPatternOnElementSelected); var bListenerExistsForElementRemovedFromSelectionEvent = AutomationPeer.ListenerExistsHelper(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); if (bListenerExistsForPropertyChangedEvent || bListenerExistsForElementSelectedEvent || bListenerExistsForElementRemovedFromSelectionEvent) { automationPeer = GetOrCreateAutomationPeer(); var spOldValue = (bool?)args.OldValue; var spNewValue = (bool?)args.NewValue; if (spOldValue != null) { bOldValue = spOldValue.Value; } if (spNewValue != null) { bNewValue = spNewValue.Value; } } if (automationPeer != null) { if (bListenerExistsForPropertyChangedEvent) { if (automationPeer is RadioButtonAutomationPeer radioButtonAutomationPeer) { radioButtonAutomationPeer.RaiseIsSelectedPropertyChangedEvent(bOldValue, bNewValue); } } if (bOldValue != bNewValue) { if (bListenerExistsForElementSelectedEvent && bNewValue) { automationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } if (bListenerExistsForElementRemovedFromSelectionEvent && !bNewValue) { automationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } } }