diff --git a/src/Uno.UI/DirectUI/XboxUtility.cs b/src/Uno.UI/DirectUI/XboxUtility.cs new file mode 100644 index 000000000000..abbd350f783a --- /dev/null +++ b/src/Uno.UI/DirectUI/XboxUtility.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.System; + +namespace DirectUI; + +internal static class XboxUtility +{ + internal static bool IsGamepadNavigationInput(VirtualKey key) + { + return (int)key >= (int)VirtualKey.GamepadA && (int)key <= (int)VirtualKey.GamepadRightThumbstickLeft; + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.Properties.cs b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.Properties.cs index 1df58485173f..cb599ba2df4e 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.Properties.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.Properties.cs @@ -49,10 +49,7 @@ public object Header typeof(ComboBox), new FrameworkPropertyMetadata( defaultValue: null, - options: FrameworkPropertyMetadataOptions.None, - propertyChangedCallback: (s, e) => ((ComboBox)s)?.UpdateHeaderVisibility() - ) - ); + options: FrameworkPropertyMetadataOptions.None)); /// /// Gets or sets the DataTemplate used to display the content of the control's header. @@ -73,10 +70,7 @@ public DataTemplate HeaderTemplate typeof(ComboBox), new FrameworkPropertyMetadata( defaultValue: null, - options: FrameworkPropertyMetadataOptions.ValueDoesNotInheritDataContext, - propertyChangedCallback: (s, e) => ((ComboBox)s)?.UpdateHeaderVisibility() - ) - ); + options: FrameworkPropertyMetadataOptions.ValueDoesNotInheritDataContext)); /// /// Gets or sets a value that indicates whether the user can diff --git a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.cs b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.cs index 12add807072c..54736096ed88 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.cs @@ -54,8 +54,6 @@ public partial class ComboBox : Selector private int m_indexForcedToUnselectedVisual = -1; private int m_indexForcedToSelectedVisual = -1; - private bool _wasPointerPressed; - /// /// The 'inline' parent view of the selected item within the dropdown list. This is only set if SelectedItem is a view type. /// diff --git a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.h.mux.cs b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.h.mux.cs index 7ca5800fa66f..9bb5148edb9b 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.h.mux.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.h.mux.cs @@ -12,9 +12,12 @@ namespace Microsoft.UI.Xaml.Controls; partial class ComboBox { - private bool m_isInSearchingMode; +#pragma warning disable CS0649 // never assigned to, and will always have its default value false +#pragma warning disable CS0414 // never assigned to, and will always have its default value false + private bool m_handledGamepadOrRemoteKeyDown; private bool m_ignoreCancelKeyDowns; private bool m_isEditModeConfigured; + private bool m_isInSearchingMode; // On pointer released we perform some actions depending on control. We decide to whether to perform them // depending on some parameters including but not limited to whether released is followed by a pressed, which diff --git a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs index 030aaa61d605..689cebf82c80 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; -using System.Linq; using DirectUI; using Microsoft.UI.Input; using Microsoft.UI.Xaml.Controls.Primitives; @@ -70,10 +69,10 @@ private void SetupEditableMode() if (m_tpDropDownOverlayPart is not null) { m_tpDropDownOverlayPart.PointerEntered += OnDropDownOverlayPointerEntered; - m_spDropDownOverlayPointerEnteredHandler.Disposable = Disposable.Create(() => m_tpContentPresenterPart.PointerEntered -= OnDropDownOverlayPointerEntered); + m_spDropDownOverlayPointerEnteredHandler.Disposable = Disposable.Create(() => m_tpDropDownOverlayPart.PointerEntered -= OnDropDownOverlayPointerEntered); m_tpDropDownOverlayPart.PointerExited += OnDropDownOverlayPointerExited; - m_spDropDownOverlayPointerExitedHandler.Disposable = Disposable.Create(() => m_tpContentPresenterPart.PointerExited -= OnDropDownOverlayPointerExited); + m_spDropDownOverlayPointerExitedHandler.Disposable = Disposable.Create(() => m_tpDropDownOverlayPart.PointerExited -= OnDropDownOverlayPointerExited); m_tpDropDownOverlayPart.Visibility = Visibility.Visible; } @@ -86,13 +85,14 @@ private void SetupEditableMode() ResetSearch(); ResetSearchString(); - wrl::ComPtr context; - get_ValidationContext(&context)); - pEditableTextPartAsTextBox.ValidationContext(context.Get())); + // TODO Uno: Input validation support #4839 + //wrl::ComPtr context; + //get_ValidationContext(&context)); + //pEditableTextPartAsTextBox.ValidationContext(context.Get())); - wrl::ComPtr command; - get_ValidationCommand(&command)); - pEditableTextPartAsTextBox->put_ValidationCommand(command.Get())); + //wrl::ComPtr command; + //get_ValidationCommand(&command)); + //pEditableTextPartAsTextBox->put_ValidationCommand(command.Get())); if (m_tpPopupPart is not null) { @@ -129,10 +129,8 @@ private void DisableEditableMode() if (m_tpDropDownOverlayPart is not null) { - var pDropDownOverlayPartAsI = iinspectable_cast(m_tpDropDownOverlayPart.Cast()); - - m_spDropDownOverlayPointerEnteredHandler.DetachEventHandler(pDropDownOverlayPartAsI)); - m_spDropDownOverlayPointerExitedHandler.DetachEventHandler(pDropDownOverlayPartAsI)); + m_spDropDownOverlayPointerEnteredHandler.Disposable = null; + m_spDropDownOverlayPointerExitedHandler.Disposable = null; m_tpDropDownOverlayPart.Visibility = Visibility.Collapsed; } @@ -621,7 +619,7 @@ private void UpdateEditableContentPresenterTextBlock(object item) } EnsurePropertyPathListener(); - var itemString = TryGetStringValue(item) //, m_spPropertyPathListener); TODO Uno: Missing PropertyPathListener support + var itemString = TryGetStringValue(item); //, m_spPropertyPathListener); TODO Uno: Missing PropertyPathListener support UpdateEditableContentPresenterTextBlock(itemString); } @@ -699,8 +697,7 @@ private void CommitRevertEditableSearch(bool restoreValue) if (m_customValueRef is not null) { - wrl_wrappers::HString storedString; - IValueBoxer::UnboxValue(m_customValueRef.Get(), storedString.GetAddressOf()); + var storedString = m_customValueRef as string; // Prevent sending the event if the custom value is the same. sendEvent = !AreStringsEqual(storedString, searchString); @@ -708,8 +705,7 @@ private void CommitRevertEditableSearch(bool restoreValue) if (sendEvent) { - ctl::ComPtr spInspectable; - PropertyValue::CreateFromString(searchString, &spInspectable)); + var spInspectable = searchString; bool isHandled = RaiseTextSubmittedEvent(searchString); @@ -845,7 +841,6 @@ private void OnKeyDownPrivate(object pSender, KeyRoutedEventArgs pArgs) m_handledGamepadOrRemoteKeyDown = eventHandled && XboxUtility.IsGamepadNavigationInput(originalKey); } - private void OnTextBoxTextChanged(object sender, TextChangedEventArgs args) { //DEAD_CODE_REMOVAL @@ -893,7 +888,7 @@ protected override void OnPointerEntered(PointerRoutedEventArgs e) if (isEventSourceTarget) { - m_isPointerOverMain = true; + m_IsPointerOverMain = true; m_bIsPressed = false; UpdateVisualState(); } @@ -1434,7 +1429,7 @@ private bool StartsWithIgnoreLinguisticSemantics(string strSource, string strPre return strSource.StartsWith(strPrefix, StringComparison.InvariantCultureIgnoreCase); } - private bool AreStringsEqual(string str1, string str2) => string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase); + private bool AreStringsEqual(string? str1, string? str2) => string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase); private bool IsSearchStringValid(string str) { @@ -1628,7 +1623,7 @@ private bool IsChildOfTarget( return result; } - private InputDeviceType GetInputDeviceTypeUsedToOpen() => m_inputDeviceTypeUsedToOpen; + internal InputDeviceType GetInputDeviceTypeUsedToOpen() => m_inputDeviceTypeUsedToOpen; private void OverrideSelectedIndexForVisualStates(int selectedIndexOverride) { @@ -1736,4 +1731,21 @@ private void CreateEditableContentPresenterTextBlock() m_tpEditableContentPresenterTextBlock = spTextBlock; } } + + +#if HAS_UNO // Not ported yet + private void SetContentPresenter(int value) { } + + private void PopupKeyDown(KeyRoutedEventArgs args) { } + + private void MainKeyDown(KeyRoutedEventArgs args) { } + + private void ArrangePopup(bool value) { } + + private void EnsurePresenterReadyForFullMode() { } + + private void EnsurePresenterReadyForInlineMode() { } + + private void ForceApplyInlineLayoutUpdate() { } +#endif } diff --git a/src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs b/src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs index 3bf202069748..4334f3e0ea02 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs @@ -218,6 +218,15 @@ public PopupPlacementMode DesiredPlacement typeof(Popup), new FrameworkPropertyMetadata(PopupPlacementMode.Auto, FrameworkPropertyMetadataOptions.AffectsArrange)); + internal DependencyObject OverlayInputPassThroughElement + { + get => (DependencyObject)GetValue(OverlayInputPassThroughElementProperty); + set => SetValue(OverlayInputPassThroughElementProperty, value); + } + + internal static DependencyProperty OverlayInputPassThroughElementProperty { get; } = + DependencyProperty.Register(nameof(OverlayInputPassThroughElement), typeof(DependencyObject), typeof(Popup), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.ValueDoesNotInheritDataContext)); + /// /// Gets the actual placement of the popup, in relation to its placement target. ///