Alexander,

Thanks for your answer.

But I use the EventListener "contextmenu" to display my context menu in 
the tree, I also use a function to create the customized menu with this 
case code I don't know where place the "this.remove".

Please find attach a sample of my code.


--------------------------------------------
function initPopUpMenuAdd(app){
   var cmenu = new qx.ui.menu.Menu;
   var r_1 = new qx.ui.menu.Button(app.label.m_ppa_1, 
"icon/add16.png",                                                 app._pmadd);
   cmenu.add(r_1);
   cmenu.addToDocument();
   app.widgets['cmenu'] = cmenu;
   return cmenu;
}

// show the context-menu
this.widgets['appTree'].addEventListener("contextmenu", function(e){
   if (this.widgets['appTree'].getSelectedElement() instanceof 
qx.ui.tree.TreeFile) {
        
this.widgets['appTree'].setContextMenu(initPopUpMenu(this,this.widgets['appTree'].getSelectedElement().getUserData("_val")));
   }else {
        this.widgets['appTree'].setContextMenu(initPopUpMenuAdd(this));
   }
   this.widgets['appTree'].getContextMenu().setLeft(e.getClientX());
   this.widgets['appTree'].getContextMenu().setTop(e.getClientY());
   this.widgets['appTree'].getContextMenu().setOpener(this);
   this.widgets['appTree'].getContextMenu().show();
}, this);




Alexander Back a écrit :
> Hi,
> 
> geo wrote:
>> Alexander.
>>
>> you're right I create the menu each time, the items of my trees are 
>> customized. So each menu is different.
> Completely different? If not, you can create a pool of contextmenus and 
> reuse them.
> 
>> Thanks for your help, but just one question is there a way to remove 
>> each time the custom menu from the page when it disappear?
> You can remove every widget from the document by calling the "remove" 
> method. This will also remove the connected DOM node from the document.
> 
> --snip--
> this._contextmenu = new qx.ui.menu.Menu();
> 
> // add - this refers to the application context
> this.add(this._contextmenu);
> 
> // remove
> this.remove(this._contextmenu);
> --snip--
> 
> cheers,
>    Alex
> 
>> Thanks ...
>>
>> Regards
>>
>> Alexander Back a écrit :
>>> Hi,
>>>
>>> geo wrote:
>>>> Alexander,
>>>>
>>>> I noticed the problem in firebug (1.2.0) with Firefox 2.0.0.16 (cf. 
>>>> qooxdoo.png).
>>>> Whenever I open a context menu, a new div appears on the page, but as 
>>>> soon as the menu disappears this "div" is hidden (display: none) and it 
>>>> does not removed.
>>> Yes, for every menu widget (a context menu is technically the same) a 
>>> DIV element is created and is hidden whenever the menu disappears. Once 
>>> the menu is opened again the same (already rendered) DIV element is used 
>>> to let it re-appear. So the DIV element will stay inside the DOM for 
>>> performance issues - it is faster to show a already menu than to 
>>> re-create it over and over again.
>>>
>>>> Then when I open a new context menu a new div is created in the page.
>>>> The only difference between these div is the position left and top...
>>>> After 10 menu display we have 10 new div which arise and so on.
>>>>
>>>> In my application I have only one context menu on a tree view,
>>>> I even succeeded to display my menu 2 times in the same position, in 
>>>> this case I have two div totally identical on the page.
>>> I wonder how you achieve this. The default behaviour of every menu 
>>> widget is to reuse its DIV element.
>>>> I use qooxdoo 0.7.3 sdk.
>>>>
>>>> I hope this will help you else I can send you a copy of the code that I 
>>>> use.
>>> Yepp, a little snippet of your code would help me to track down this 
>>> problem. However, I guess you are creating your contextmenu every time 
>>> somebody is right-clicking at your tree view, which will create a new 
>>> menu instance (and a new DIV element) of course. So instead of creating 
>>> every time a new one you have to reuse the already existing.
>>>
>>> --snip--
>>> // just a little example to show the reusing - don't know if it's 
>>> working completely
>>>
>>> _contextmenu : null,
>>>
>>> _createTree : function(){
>>>    myTreeView = new qx.ui.tree.Tree;
>>>
>>>    // "this" refers to the application context
>>>    myTreeView.addEventListener("contextmenu", this._showContextMenu, this);
>>>    ...
>>> },
>>>
>>> _showContextMenu : function(e){
>>>    // if the contextmenu is not created
>>>    if (this._contextmenu == null)
>>>    {
>>>        this._contextmenu = new qx.ui.menu.Menu;
>>>        // menu details
>>>    }
>>>
>>>    // position the contextmenu using the event coords
>>>    this._contextmenu.setLeft(e.getScreenX() + 10);
>>>    this._contextmenu.setTop(e.getScreenY() + 10);
>>>
>>>    this._contextmenu.show();
>>> }
>>> --snip--
>>>
>>> Hope this helps,
>>>    Alex
>>>
>>>> Thanks.
>>>>
>>>>
>>>> Alexander Back a écrit :
>>>>> Hi,
>>>>>
>>>>> geo wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I found during using the contextual menu, that they are not deleted 
>>>>>> from the page but just hidden.
>>>>>> Whenever you display a context menu that creates a new <div> in the 
>>>>>> page.
>>>>>> Is there a way to avoid this?
>>>>> qooxdoo widgets are tied to their DOM nodes. In the case of the 
>>>>> contextmenu the same DIV node is used, it is just hidden and displayed.
>>>>> Are you sure you talking about the same DIV as used for the contextmenu?
>>>>>
>>>>> cheers,
>>>>>    Alex
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to