diff mde/gui/WidgetManager.d @ 167:620d4ea30228

Context menus: added a clipboard (functions accessible from main menu rather than context menu).
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 27 Jun 2009 11:57:26 +0200
parents 55667d048c31
children da8d3091fdaf
line wrap: on
line diff
--- a/mde/gui/WidgetManager.d	Sun Jun 21 12:19:18 2009 +0200
+++ b/mde/gui/WidgetManager.d	Sat Jun 27 11:57:26 2009 +0200
@@ -29,6 +29,7 @@
 
 import imde = mde.imde;
 import mde.content.Content;
+import mde.content.ServiceContent;
 debug import mde.content.miscContent;	// Debug menu
 
 // Widgets to create:
@@ -72,6 +73,11 @@
         auto p = "MiscOptions.l10n" in Content.allContent;
         assert (p, "MiscOptions.l10n not created!");
         p.addCallback (&reloadStrings);
+	
+	serviceContent = cast (IServiceContent) Content.get ("menus.services");
+	assert (Content.get ("menus.services"));
+	assert (serviceContent !is null, "Content service menu doesn't exist or has wrong type");
+	
         debug {	// add a debug-mode menu
             auto lWS = new EventContent ("menus.debug."~name~".logWidgetSize");
             lWS.addCallback (&logWidgetSize);
@@ -321,9 +327,10 @@
 	
 	// Finally, post the actual event:
 	if (b == 3 && !state) {	// right click - open context menu
-	    IContent contextContent = underMouse.content;
+	    Content contextContent = cast(Content)underMouse.content;
 	    if (contextContent is null) return;
 	    // NOTE: Creates new widgets every time; not optimal
+	    serviceContent.setContent (contextContent);
 	    popupContext = makeWidget (this, "context", contextContent);
 	    popupContext.setup (0, 3);
 	    positionPopup (underMouse, popupContext);
@@ -524,6 +531,7 @@
     
     // Popup(s) handled directly by AWidgetManager:
     IChildWidget popupContext;		// context menu (active if not null)
+    IServiceContent serviceContent;	// context menu content tree
     IChildWidget dragContentDisplay;	// displays dragged content; no interaction
     
     IChildWidget dragStart;		// if non-null, this widget should receive motion and click-release events