About right-clicked popup menu on ComboBox


#1

I have definition the mouse right-click pop-up menu or showMessageBox, but when I right-click and mouse cursor on any ComboBox, ComboBox’s menu also appears, how does not appear?

thx!


#2

Sorry, I’m struggling to understand your english a bit there… Can you try to explain again?


#3

such as: component A consists of many sub-components, ComboBox, Button, Label, etc. I want: after mouse right-click on Component A, display a pop-up menu, or display a pop-up message window.

Everything was nice. I used an invisible component as a container to display the context menu when mouse right-clicked. rewrite mouseDown().

But, when the position has mouse right-clicked that on any ComboBox, ComboBox’s list menu and pop-up contex menu displayed at the same time.

so, two menu let me puzzled.

BTW,I found JUCE‘s mouse left button and right button to do the same thing (click button etc. ), it makes me surprising also…


#4

Do you mean that you’ve got your own component in front of the ComboBox (i.e. covering it), but the combobox is still receiving mouse-clicks through your component?


#5

No.
My component only handle mouse right-click,to display context menu (pop-up menu). This component is invisible, if not, other component (button, combobox etc.) can’t operate.

but, when right-click on combobox, the combobox’s list menu and invisible component’s context menu display at same time, so, two menu on screen…This is obviously not what I want.

My English so poor…I was so depressed… :cry:


#6

英语不好,简单的问题也描述不清,实在汗颜。有哪位国内的JUCE同仁能帮忙转述一下吗?万二分感激!

我的问题是:
JUCE的鼠标左键和右键不区分,比如点击按钮、Combobox组合框等等,左键和右键的效果是一样的。

我有一个屏幕操作区域,在该区域中的任何位置,单击鼠标右键,将弹出上下文菜单,也就是右键菜单。同时,该区域中还有其它子组件,比如按钮、标签、组合框等等。正确的效果应该是:鼠标左键点击按钮、组合框等控件,进行对应的操作,而鼠标右键点击时,只出现上下文菜单。

但是,由于组合框也响应鼠标右键单击,因此,在组合框的位置点击鼠标右键之后,上下文菜单和组合框本身的下拉列表同时出现了——也就是屏幕上出现了两个菜单,即使点击了上下文菜单中的某个菜单项,组合框的下拉列表依然不消失,这让人很困惑。

我想要的效果是:鼠标左键点击控件,一切如常,该怎么地就怎么地,而鼠标右键单击时,只弹出上下文菜单。而不是目前这种情况:在组合框的位置点击鼠标右键,一下子弹出来两个菜单。


#7

Solved. I had to write a derived class, only for cancel the ComboBox’s pop-up menu when right-clicked on this.

my code:

class MyComboBox:public ComboBox { public: void mouseDown(const MouseEvent& e) { if (e.mods.isLeftButtonDown()) showPopup(); } };


#8

I don‘t understand, why the mouse left click and right click to do the same thing on JUCE’s buttons, comboboxes, etc. ? By default, the right mouse button should not operate them.


#9

By this, I learned some JUCE knowledge, although very difficult to explore, but very happy.

Thanks Jules.


#10

Why not? There’s no reason why it shouldn’t do the same thing. I think some people make buttons perform different tasks depending on the button that clicked it. (That’s probably not something I’d ever do myself, but there may be contexts where it’d be useful).

It looks like the combo box actually does behave a little strangely when you right-click it though - I guess I never tried doing that before. I’ll tidy that up, so it just ignores right-clicks.


#11

Yes. This operation is indeed very flexible.

However, a region has a right click pop-up menu, the region also contains a combo box, the user probably right-click that the position just on combobox…then, two menu on screen (combobox’s menu and regional right-click menu) , this will make them confused.