Thanks Martin!

I needed a popup over a table widget which has no fixed width, which created
some proplems. Here is your adapted code that works for me:

     createPopup : function()
     {
        this.__loadingPopup = new qx.ui.popup.Popup(new
qx.ui.layout.Canvas()).set({
          decorator: "group",
          width : 100,
          height : 50,
          padding : 10
        });
        this.__loadingPopup.add( new qx.ui.basic.Atom("Loading...",
"path/to/ajax-loader.gif") );
     },
     
     showPopup : function( w )
     {
       var p = this.__loadingPopup;
       var c,l,t,w,h;
       if ( w  ) 
       {
          c = w.getContentLocation();
          if ( c )
          {
            var w = c.right - c.left;
            var h = c.bottom - c.top;
            l = Math.floor( c.left + ( w / 2) - ( p.getWidth() / 2 ) ); 
            t = Math.floor( c.top + ( h / 2) - ( p.getHeight() / 2) );
          }
       }
       if ( w && l && t)
       {
         p.placeToPoint({left: l, top: t}); // we have valid paramters 
       }
       else
       {
         l =  Math.floor( ( qx.bom.Document.getWidth() / 2 ) - (
p.getWidth() / 2 ) );
         t =  Math.floor( ( qx.bom.Document.getHeight() / 2 ) - (
p.getHeight() / 2 ) );
         p.placeToPoint({left: l, top: t}); // place it in the middle of the
screen 
       }
       p.show();      
     },
     
     hidePopup : function()
     {
       this.__loadingPopup.hide();
     },

The code has a fallback for cases that the widget has'nt rendered yet, then
the popup is places in the middle of the screen.

Thanks again for your quick help!

Christian 

-- 
View this message in context: 
http://n2.nabble.com/Center-a-popup-over-a-widget-tp4925313p4926119.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to