Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPF - Allow ToolTip timer configuration #4389

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,16 +1603,18 @@ private static void OnTooltipTextChanged(DependencyObject d, DependencyPropertyC
/// <param name="newValue">new value</param>
protected virtual void OnTooltipTextChanged(string oldValue, string newValue)
{
var timer = tooltipTimer;
if (timer == null)
// There are cases where oldValue is null and newValue is string.Empty
// and vice versa, simply ignore when string.IsNullOrEmpty for both.
if (string.IsNullOrEmpty(oldValue) && string.IsNullOrEmpty(newValue))
{
return;
}

// There are cases where oldValue is null and newValue is string.Empty
// and vice versa, simply ignore when string.IsNullOrEmpty for both.
if (string.IsNullOrEmpty(oldValue) && string.IsNullOrEmpty(newValue))
var timer = tooltipTimer;
if (timer == null)
{
OpenOrCloseToolTip(newValue);

return;
}

Expand Down Expand Up @@ -2056,14 +2058,18 @@ private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArg
/// <param name="routedEventArgs">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
// TODO: Consider making the delay here configurable.
tooltipTimer = new DispatcherTimer(
TimeSpan.FromSeconds(0.5),
DispatcherPriority.Render,
OnTooltipTimerTick,
Dispatcher
);
tooltipTimer.IsEnabled = false;
var initialShowDelay = ToolTipService.GetInitialShowDelay(this);

if (initialShowDelay > 0)
{
tooltipTimer = new DispatcherTimer(
TimeSpan.FromMilliseconds(initialShowDelay),
DispatcherPriority.Render,
OnTooltipTimerTick,
Dispatcher
);
tooltipTimer.IsEnabled = false;
}

//Initial value for screen location
browserScreenLocation = GetBrowserScreenLocation();
Expand Down