Problem on context menu display

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem on context menu display

voger
I have this playground code http://tinyurl.com/lojdq96.

I am trying to add a context menu to a button. Unfortunately it is a mess.

First I try, maybe, I can capture the right click

button.addListener('click', function(e){
   var click = e.getButton();
   console.log(click);
});

This almost never (99% of the time) works in Chrome. In Firefox it works
always.

Alternative. I try to catch the 'contextmenu' event.

button.addListener('contextmenu', function(){
   button.setContextMenu(cmenu(button));
});

function cmenu(button){
   var menu = new qx.ui.menu.Menu(button);
   menu.placeToWidget(button, true);
   var button1 = new qx.ui.menu.Button('Test1');
   menu.add(button1);
   return menu;
}

This works but:
1. Sometimes it needs two right clicks to display the menu
2. The menu first pops at the mouse pointer and then jumps under the
button. This is more visible in Firefox.

How can I display a context menu properly?

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem on context menu display

voger
I made few more experiments

nr. 1 http://tinyurl.com/k5rdl8o
With this the menu appears always but only the first time it displays
under the widget. In subsequent appearances it displays in the cursor.
What I am doing wrong here?

nr. 2 http://tinyurl.com/ljh92ms
This is more consistent.

My goal is to make a dynamic context menu so it appears that I have to
define/change the menu earlier than the contextmenu event. I hope this
is the correct fix.

I am curious. Still the right click event it is not reported in Chrome
(no console.log()). In Firefox it gets captured and reported in Firebug.
Is this a bug/inconsistency of browser or something I do wrong?



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem on context menu display

Tobias Oberrauch
Hi,

you can define the menu on pointerover.
Furthermore you have to use MenuButton.

I tried to build an example: http://tinyurl.com/lc2yzez

__tl;tr;__
var button = new qx.ui.form.MenuButton("Button");
button.addListener("pointerover", function () {
  this.setMenu(getMenu());
});
doc.add(button);


Cheers Tobias


Am Montag, den 16.03.2015, 00:50 +0200 schrieb voger:

> I made few more experiments
>
> nr. 1 http://tinyurl.com/k5rdl8o
> With this the menu appears always but only the first time it displays
> under the widget. In subsequent appearances it displays in the cursor.
> What I am doing wrong here?
>
> nr. 2 http://tinyurl.com/ljh92ms
> This is more consistent.
>
> My goal is to make a dynamic context menu so it appears that I have to
> define/change the menu earlier than the contextmenu event. I hope this
> is the correct fix.
>
> I am curious. Still the right click event it is not reported in Chrome
> (no console.log()). In Firefox it gets captured and reported in Firebug.
> Is this a bug/inconsistency of browser or something I do wrong?
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem on context menu display

voger
Thanks. The 'pointerover' event is a good idea.
Unfortunately I need a context menu that activates on right click. When
I switched your example from getMenu() to getContextMenu() I get the
same behavior. http://tinyurl.com/llnsued

I thought that this code as I have in the previous playground should do
the trick

button.addListener('beforeContextmenuOpen', function(e){
   var menu =this.getContextMenu();
   menu.setPlaceMethod('widget');
   menu.placeToWidget(button, true);
});

but I can't get the event 'beforeContextmenuOpen' to work in my project.
If I replace it with 'contextmenu' I can listen it it works but it
doesn't do what I want. I spent the last 5 hours trying to understand
why the event is not working but I can't get anything reasonable.


On 16/03/2015 05:44 μμ, Tobias Oberrauch wrote:

> Hi,
>
> you can define the menu on pointerover.
> Furthermore you have to use MenuButton.
>
> I tried to build an example: http://tinyurl.com/lc2yzez
>
> __tl;tr;__
> var button = new qx.ui.form.MenuButton("Button");
> button.addListener("pointerover", function () {
>    this.setMenu(getMenu());
> });
> doc.add(button);
>
>
> Cheers Tobias
>
>
> Am Montag, den 16.03.2015, 00:50 +0200 schrieb voger:
>> I made few more experiments
>>
>> nr. 1 http://tinyurl.com/k5rdl8o
>> With this the menu appears always but only the first time it displays
>> under the widget. In subsequent appearances it displays in the cursor.
>> What I am doing wrong here?
>>
>> nr. 2 http://tinyurl.com/ljh92ms
>> This is more consistent.
>>
>> My goal is to make a dynamic context menu so it appears that I have to
>> define/change the menu earlier than the contextmenu event. I hope this
>> is the correct fix.
>>
>> I am curious. Still the right click event it is not reported in Chrome
>> (no console.log()). In Firefox it gets captured and reported in Firebug.
>> Is this a bug/inconsistency of browser or something I do wrong?
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub for all
>> things parallel software development, from weekly thought leadership blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel