Skip to content

Commit

Permalink
windows statusicon: fix submenu item clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
hbons committed Dec 2, 2012
1 parent fabeede commit 643fbed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 13 additions & 5 deletions SparkleShare/Windows/SparkleNotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
Expand Down Expand Up @@ -253,11 +254,18 @@ private int OnMouseEventProc (int code, int button, IntPtr data_pointer)
try {
if (button == left_button_down || button == right_button_down)
{
Rect context_menu_rect = GetContextMenuRect(ContextMenu);
Point hit_point = GetHitPoint(data_pointer);

if (!context_menu_rect.Contains(hit_point))
ContextMenu.IsOpen = false;
Rect context_menu_rect = GetContextMenuRect (ContextMenu);
Point hit_point = GetHitPoint (data_pointer);

if (!context_menu_rect.Contains(hit_point)) {
new Thread (() => {
Thread.Sleep (500);
Dispatcher.BeginInvoke ((Action) delegate {
ContextMenu.IsOpen = false;
});
}).Start ();
}
}
}
finally {
Expand Down
10 changes: 5 additions & 5 deletions SparkleShare/Windows/SparkleStatusIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public void CreateMenu ()
this.exit_item = new SparkleMenuItem () { Header = "Exit" };


add_item.Click += Controller.AddHostedProjectClicked;
this.log_item.Click += Controller.RecentEventsClicked;
about_item.Click += Controller.AboutClicked;
add_item.Click += delegate { Controller.AddHostedProjectClicked (); };
this.log_item.Click += delegate { Controller.RecentEventsClicked (); };
about_item.Click += delegate { Controller.AboutClicked (); };

notify_check_box.Click += delegate {
this.context_menu.IsOpen = false;
Expand Down Expand Up @@ -198,15 +198,15 @@ public void CreateMenu ()
Header = "Try again"
};

try_again_item.Click += Controller.TryAgainDelegate (folder_name);
try_again_item.Click += delegate { Controller.TryAgainDelegate (folder_name); };

subfolder_item.Items.Add (error_item);
subfolder_item.Items.Add (new Separator ());
subfolder_item.Items.Add (try_again_item);

} else {
subfolder_item.Icon = subfolder_image;
subfolder_item.Click += Controller.OpenFolderDelegate (folder_name);
subfolder_item.Click += delegate { Controller.OpenFolderDelegate (folder_name); };
}

this.context_menu.Items.Add (subfolder_item);
Expand Down

0 comments on commit 643fbed

Please sign in to comment.