Home » U++ Library support » Menus&Toolbars » ToolBar's context menu
|
Re: ToolBar's context menu [message #15084 is a reply to message #15083] |
Sat, 29 March 2008 11:10 |
Oblivion
Messages: 1135 Registered: August 2007
|
Senior Contributor |
|
|
Quote: |
How to get a context menu of toolbar by right-clicking on it? Like in OperaAC toolbars, for example.
|
Well there are at least 3 ways:
1: If you want to activate the context menu with right-button down in the empty area of the Bar, just override ChildFrameEvent() method BUT don't use "child" pointer, instead use child->GetParent();
2: Better Way: If you want to activate context menu even when the tool buttons are pressed with the rigth buttons (or if you want to assign different context menus to tool buttons, use:
void BarContext::ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags)
{
if(toolbar.HasChildDeep(child)) // Effects tool buttons too... (just specify which button, then you'll get different menus for each button)
{
if(event == RIGHTDOWN) MenuBar::Execute(THISBACK(SetMenuBar));
}
TopWindow::ChildMouseEvent(child, event, p, zdelta, keyflags);
}
3: Derive your class from ToolBar, then override ChildMouseEvent (imho, unnecessary)
Here is the example.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sat, 29 March 2008 11:14] Report message to a moderator
|
|
|
|
Re: ToolBar's context menu [message #15090 is a reply to message #15083] |
Sun, 30 March 2008 08:13 |
Sc0rch
Messages: 99 Registered: February 2008 Location: Russia, Rubtsovsk
|
Member |
|
|
But what is the best way to determine which button was clicked? My code uses ctrl-descriptions for this purpose, but it is not the best way, I think.
Added: the variant below works too:
void BarContext::ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags)
{
if(toolbar.HasChildDeep(child))
{
if(event == RIGHTDOWN)
{
Ctrl *c = child;
int i = -1;
while (c != NULL)
{
c = c->GetPrev();
i++;
}
MenuBar::Execute(THISBACK1(SetMenuBar, i));
}
}
Ctrl::ChildMouseEvent(child, event, p, zdelta, keyflags);
}
Anton
[Updated on: Sun, 30 March 2008 14:54] Report message to a moderator
|
|
|
Re: ToolBar's context menu [message #26933 is a reply to message #15084] |
Thu, 10 June 2010 16:22 |
|
Oblivion wrote on Sat, 29 March 2008 12:10 |
Quote: |
How to get a context menu of toolbar by right-clicking on it? Like in OperaAC toolbars, for example.
|
Well there are at least 3 ways:
1: If you want to activate the context menu with right-button down in the empty area of the Bar, just override ChildFrameEvent() method BUT don't use "child" pointer, instead use child->GetParent();
2: Better Way: If you want to activate context menu even when the tool buttons are pressed with the rigth buttons (or if you want to assign different context menus to tool buttons, use:
void BarContext::ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags)
{
if(toolbar.HasChildDeep(child)) // Effects tool buttons too... (just specify which button, then you'll get different menus for each button)
{
if(event == RIGHTDOWN) MenuBar::Execute(THISBACK(SetMenuBar));
}
TopWindow::ChildMouseEvent(child, event, p, zdelta, keyflags);
}
3: Derive your class from ToolBar, then override ChildMouseEvent (imho, unnecessary)
Here is the example.
|
Your method did not work for toolbutton!
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:40:50 CET 2024
Total time taken to generate the page: 0.02314 seconds
|