r9779: Add a contextmenu function to be used by all window/widget objects.
authorDeryck Hodge <deryck@samba.org>
Tue, 30 Aug 2005 03:55:08 +0000 (03:55 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:35:00 +0000 (13:35 -0500)
deryck

swat/desktop/index.esp
swat/scripting/client/desktop.js

index ee4290f234c5c53dc06be697caa06589f81a8fa4..0714a2d038fbb89147a6f77e21cbadeb618de222 100644 (file)
@@ -51,30 +51,6 @@ function blankW()
        blank.setVisible(true);
 }
 
        blank.setVisible(true);
 }
 
-function showContextMenu(e)
-{
-       var aboutCmd = new QxCommand();
-       aboutCmd.addEventListener("execute", function() {
-               showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
-       });
-
-       var newWin = new QxCommand();
-       newWin.addEventListener("execute", blankW);
-
-       cmenu = new QxMenu;
-
-       var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
-       var sep = new QxMenuSeparator();
-       var sub2 = new QxMenuButton("New Window", null, newWin);
-
-       cmenu.add(sub1, sep, sub2);
-
-       cmenu.setLeft(e.getClientX());
-       cmenu.setTop(e.getClientY());
-       w.add(cmenu);
-       cmenu.setVisible(true);
-}
-
 // Always open with stats
 var win = new QxWindow();
 document.js.add('/scripting/client/status.js');
 // Always open with stats
 var win = new QxWindow();
 document.js.add('/scripting/client/status.js');
@@ -116,6 +92,48 @@ function showReg()
        regWin.setVisible('true');
 }
 
        regWin.setVisible('true');
 }
 
+function clientContextMenu(e)
+{
+       var aboutCmd = new QxCommand();
+       aboutCmd.addEventListener("execute", function() {
+               showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
+       });
+
+       var newWin = new QxCommand();
+       newWin.addEventListener("execute", blankW);
+
+       var cmenu = new QxMenu;
+
+       var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
+       var sep = new QxMenuSeparator();
+       var sub2 = new QxMenuButton("New Window", null, newWin);
+
+       cmenu.add(sub1, sep, sub2);
+
+       cmenu.setLeft(e.getClientX());
+       cmenu.setTop(e.getClientY());
+       w.add(cmenu);
+       cmenu.setVisible(true);
+}
+
+function windowContextMenu(t, e)
+{
+       var WinWin = new QxCommand();
+       WinWin.addEventListener("execute", function() {
+               var blank = new QxWindow();
+               t.add(blank);
+               blank.setVisible(true);
+       }); 
+
+       var inset = new QxMenu;
+       var sub1 = new QxMenuButton("Open window in a window", null, WinWin);
+
+       inset.add(sub1);
+       t.add(inset)
+
+       inset.setVisible(true);
+}
+
 function startMenu() 
 {
        var sMenu = new QxMenu;
 function startMenu() 
 {
        var sMenu = new QxMenu;
index 6383e58bdae4b9cd7f094102fdc2911455658a95..bddd38b60c8bfea88eae1faa030edd9284bababf 100644 (file)
@@ -89,26 +89,6 @@ function openIn(e)
        blank.setVisible(true);
 }
        
        blank.setVisible(true);
 }
        
-function winMenu(e)
-{
-       var self = this;
-       var WinWin = new QxCommand();
-       WinWin.addEventListener("execute", function() {
-               var blank = new QxWindow();
-               self.add(blank);
-               blank.setVisible(true);
-       }); 
-
-       var inset = new QxMenu;
-       var sub1 = new QxMenuButton("Open window in a window", null, WinWin);
-
-       inset.add(sub1);
-       self.add(inset)
-
-       cmenu.setVisible(false);
-       inset.setVisible(true);
-}
-
 function Window(h, src, s)
 {
        this.self = new QxWindow(h);
 function Window(h, src, s)
 {
        this.self = new QxWindow(h);
@@ -121,7 +101,7 @@ function Window(h, src, s)
        this.self.setTop(getPosX(this.self));
        this.self.setLeft(getPosY(this.self));
 
        this.self.setTop(getPosX(this.self));
        this.self.setLeft(getPosY(this.self));
 
-       this.self.addEventListener("contextmenu", winMenu);
+       this.self.addEventListener("contextmenu", contextMenu);
 
        return this.self;
 }
 
        return this.self;
 }
@@ -148,10 +128,23 @@ Window.small = SmallWindow;
 Window.standard = StandardWindow;
 Window.large = LargeWindow;
 
 Window.standard = StandardWindow;
 Window.large = LargeWindow;
 
+function contextMenu(e)
+{      
+       var t = e.getTarget()
+       var tObj = t.getHtmlAttribute("class")
+
+       if (tObj == 'QxWidget') {
+               clientContextMenu(e);
+       } else if (tObj == 'QxWindowPane') {
+               windowContextMenu(t, e);
+       }
+}
+
+
 window.application.main = function()
 {
        var doc = this.getClientWindow().getClientDocument();
 window.application.main = function()
 {
        var doc = this.getClientWindow().getClientDocument();
-       doc.addEventListener("contextmenu", showContextMenu);
+       doc.addEventListener("contextmenu", contextMenu);
        doc.add(w);
 
        var bar = new QxMenuBar;
        doc.add(w);
 
        var bar = new QxMenuBar;