Skip to content

Commit

Permalink
chore: Start KA ToolTip support
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jun 20, 2024
1 parent dc36808 commit 1860843
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public partial class ToolTipService
internal static DependencyProperty KeyboardAcceleratorToolTipObjectProperty { get; } =
DependencyProperty.RegisterAttached(
"KeyboardAcceleratorToolTipObject",
typeof(object),
typeof(ToolTip),
typeof(ToolTipService),
new FrameworkPropertyMetadata(default, OnToolTipChanged));

internal static object GetKeyboardAcceleratorToolTipObject(DependencyObject element) => element.GetValue(KeyboardAcceleratorToolTipObjectProperty);
internal static ToolTip GetKeyboardAcceleratorToolTipObject(DependencyObject element) => (ToolTip)element.GetValue(KeyboardAcceleratorToolTipObjectProperty);

internal static void SetKeyboardAcceleratorToolTipObject(DependencyObject element, object value) => element.SetValue(KeyboardAcceleratorToolTipObjectProperty, value);
internal static void SetKeyboardAcceleratorToolTipObject(DependencyObject element, ToolTip value) => element.SetValue(KeyboardAcceleratorToolTipObjectProperty, value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// MUX Reference dxaml\xcp\core\input\KeyboardAccelerator.cpp, tag winui3/release/1.4.3, commit 685d2bf

using DirectUI;
using Uno.UI.Extensions;
using Uno.UI.Xaml;
using Windows.System;
using static Microsoft/* UWP don't rename */.UI.Xaml.Controls._Tracing;
Expand All @@ -21,9 +22,9 @@ private void EnterImpl(

if (enterParams.IsLive)
{
//TODO:MZ Implement this
//// If there are events registered on this element, ask the
//// EventManager to extract them and create a request for every event.
//TODO:MZ Do we need this part?
// If there are events registered on this element, ask the
// EventManager to extract them and create a request for every event.
//var core = GetContext();
//if (m_pEventList)
//{
Expand All @@ -33,41 +34,40 @@ private void EnterImpl(
// IFCEXPECT_ASSERT_RETURN(pEventManager);
// IFC_RETURN(pEventManager->AddRequestsInOrder(this, m_pEventList));
//}
//KeyboardAcceleratorCollection * const pCollection = do_pointer_cast<KeyboardAcceleratorCollection>(this->GetParentInternal(false /* publicParentOnly */));
//IFCPTR_RETURN(pCollection);
//DependencyObject* pParentElement = pCollection->GetParentInternal(false /* publicParentOnly */);
KeyboardAcceleratorCollection collection = (KeyboardAcceleratorCollection)this.GetParentInternal(false /* publicParentOnly */);
DependencyObject pParentElement = collection.GetParentInternal(false /* publicParentOnly */);

//// Do not set tooltip if
//// 1. Parent element has disabled the keyboard accelerator tooltip.
//// 2. current keyboard accelerator is disabled.
// Do not set tooltip if
// 1. Parent element has disabled the keyboard accelerator tooltip.
// 2. current keyboard accelerator is disabled.

//KeyboardAcceleratorPlacementMode kaPlacementMode = KeyboardAcceleratorPlacementMode.Auto;
UIElement element = (UIElement)pParentElement;

//var kaPlacementMode = (KeyboardAcceleratorPlacementMode)element.GetValue(UIElement.KeyboardAcceleratorPlacementModeProperty);
var kaPlacementMode = (KeyboardAcceleratorPlacementMode)element.GetValue(UIElement.KeyboardAcceleratorPlacementModeProperty);

//if (kaPlacementMode == KeyboardAcceleratorPlacementMode.Hidden
// || !this.IsEnabled
// || this.m_key == VirtualKey.None)
if (kaPlacementMode == KeyboardAcceleratorPlacementMode.Hidden
|| !this.IsEnabled
|| this.Key == VirtualKey.None)

//{
// // Don't show a tooltip for an accelerator, no need to make the popup
// return;
//}
{
// Don't show a tooltip for an accelerator, no need to make the popup
return;
}

//// Create and set tooltip on parent control, only if this is the first tooltip enabled accelerator in the collection.
//foreach (DependencyObject accelerator in collection)
//{
// MUX_ASSERT(accelerator is KeyboardAccelerator);
// Create and set tooltip on parent control, only if this is the first tooltip enabled accelerator in the collection.
foreach (DependencyObject accelerator in collection)
{
MUX_ASSERT(accelerator is KeyboardAccelerator);

// if (((KeyboardAccelerator)accelerator).IsEnabled)
// {
// if (accelerator == this)
// {
// FxCallbacks.KeyboardAccelerator_SetToolTip(this, pParentElement);
// }
// break;
// }
//}
if (((KeyboardAccelerator)accelerator).IsEnabled)
{
if (accelerator == this)
{
FxCallbacks.KeyboardAccelerator_SetToolTip(this, pParentElement);
}
break;
}
}
}
}
}

0 comments on commit 1860843

Please sign in to comment.