Home » U++ Library support » Look and Chameleon Technology » undesired behavior using custom styled MenuBar
undesired behavior using custom styled MenuBar [message #37929] |
Sat, 24 November 2012 01:09 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Hi, folks!
I'm getting an undesired behavior after applying a custom styled MenuBar to a TreeCtrl. My custom MenuBar pops up unexpectedly when I change from a selected TreeBar item to the next using keyboard arrow keys. I put a case code below for your reference and help:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class MyMenuBar : public MenuBar
{
public:
typedef MyMenuBar CLASSNAME;
MyMenuBar() {
menustyle = MenuBar::StyleDefault();
menustyle.menutext = Color(198, 198, 0);
menustyle.popupframe = menustyle.popupbody = menustyle.popupiconbar = Black();
SetStyle(menustyle);
}
MenuBar::Style menustyle;
};
class MyApp : public TopWindow
{
public:
typedef MyApp CLASSNAME;
MyApp() {
tree.LeftPos(10, 300).TopPos(10, 200);
TreeCtrl::Node node;
for(int i = 0; i < 20; i++) {
node.Set(Format("item %d", i));
tree.Add(0, node);
}
tree.OpenDeep(0);
tree.WhenBar = THISBACK(HandleTreeBar);
Add(tree);
}
void HandleTreeBar(Bar& bar){
// here I use my styled MenuBar instead of TreeCtrl std bar
MyMenuBar mymenu;
mymenu.Add("foo", THISBACK(ActionSink));
mymenu.Add("bar", THISBACK(ActionSink));
mymenu.Execute();
}
void ActionSink()
{
PromptOK("Upp");
}
TreeCtrl tree;
};
GUI_APP_MAIN
{
MyApp().Run();
}
I'm not actually sure if that's the proper way to replace the TreeBar std MenuBar by my own, so anyone please point out how to do it the right way.
Shouldn't the MenuBar pop up only when RMB pressed?
Thanks!
|
|
|
Goto Forum:
Current Time: Mon May 13 23:08:30 CEST 2024
Total time taken to generate the page: 0.02099 seconds
|