Daemon status popup works

Change-Id: Ic58070ce80578593053c6f4d68df6c785dff7442
diff --git a/osx/menu-delegate.mm b/osx/menu-delegate.mm
index 35e3881..1e2b1c1 100644
--- a/osx/menu-delegate.mm
+++ b/osx/menu-delegate.mm
@@ -31,6 +31,13 @@
   [statusItem setTitle:@""];
   [statusItem setImage:menuIcon];
   
+  
+  
+  [connectionStatus setView: connectionStatusView];
+  [connectionStatus setTarget:self];
+  [daemonStatus setView: daemonStatusView];
+  [daemonStatus setTarget:self];
+
   daemonStarted = false;
 }
 
@@ -40,7 +47,8 @@
   {
     daemonStarted = false;
     [sender setTitle:@"Start"];
-    [connectionStatus setTitle:@"NDN disconnected"];
+    //[connectionStatus setTitle:@"NDN disconnected"];
+    [connectionStatusText setStringValue:@"Disconnected"];
     
     NSBundle *bundle = [NSBundle bundleForClass:[self class]];
     NSString *path = [bundle pathForResource:@"FlatDisconnected" ofType:@"png"];
@@ -51,7 +59,8 @@
   {
     daemonStarted = true;
     [sender setTitle:@"Stop"];
-    [connectionStatus setTitle:@"NDN connected"];
+    //[connectionStatus setTitle:@"NDN connected"];
+    [connectionStatusText setStringValue:@"Connected"];
     
     NSBundle *bundle = [NSBundle bundleForClass:[self class]];
     NSString *path = [bundle pathForResource:@"FlatConnected" ofType:@"png"];
@@ -62,11 +71,6 @@
 
 -(IBAction)openDaemonStatus:(id)sender
 {
-  [statusPopover showRelativeToRect:[[daemonStatus view] bounds]
-                 ofView:[daemonStatus view]
-                 preferredEdge:NSMinXEdge];
-
-  //[statusPopover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
 }
 
 -(IBAction)openRoutingStatusPage:(id)sender
@@ -84,4 +88,20 @@
   [[NSWorkspace sharedWorkspace] openURL: pageURL];
 }
 
+-(void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
+{
+
+  if( ([item view]!=nil) && (item == daemonStatus) )
+  {
+    [statusPopover showRelativeToRect:[[item view] bounds]
+                 ofView:[item view]
+                 preferredEdge:NSMinXEdge];
+    
+  }
+  else
+  {
+    [statusPopover performClose:nil];
+  }
+}
+
 @end