Skip to content

Commit

Permalink
Make open on hover a config property
Browse files Browse the repository at this point in the history
  • Loading branch information
bcssov committed May 12, 2023
1 parent 24fa914 commit c96e047
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/IronyModManager/Controls/VerticalMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
Expand All @@ -33,6 +34,16 @@ public class VerticalMenuItem : MenuItem, IStyleable
{
#region Fields

/// <summary>
/// The automatic open property
/// </summary>
public static readonly DirectProperty<VerticalMenuItem, bool> AutoOpenProperty = AvaloniaProperty.RegisterDirect<VerticalMenuItem, bool>(nameof(AutoOpen), o => o.AutoOpen, (o, v) => o.AutoOpen = v);

/// <summary>
/// The automatic open
/// </summary>
private bool autoOpen = true;

/// <summary>
/// The popup
/// </summary>
Expand All @@ -42,6 +53,16 @@ public class VerticalMenuItem : MenuItem, IStyleable

#region Properties

/// <summary>
/// Gets or sets a value indicating whether [automatic open].
/// </summary>
/// <value><c>true</c> if [automatic open]; otherwise, <c>false</c>.</value>
public bool AutoOpen
{
get { return autoOpen; }
set { SetAndRaise(AutoOpenProperty, ref autoOpen, value); }
}

/// <summary>
/// Gets the type by which the control is styled.
/// </summary>
Expand Down Expand Up @@ -76,7 +97,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
protected override void OnPointerEnter(PointerEventArgs e)
{
base.OnPointerEnter(e);
if (IsPointerOver)
if (AutoOpen && IsPointerOver)
{
var hasChildren = this.GetLogicalChildren().OfType<MenuItem>().Any();
if (hasChildren)
Expand Down

0 comments on commit c96e047

Please sign in to comment.