don't freak out if BMenuWindow::AttachScrollers() is called more than once (happens when a menu window has scrollers already, and we call BMenu::AddItem().

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24094 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2008-02-24 15:29:10 +00:00
parent a6ca2bfcec
commit 60e1cfbfbb
+16 -10
View File
@@ -280,21 +280,27 @@ BMenuWindow::DetachMenu()
void void
BMenuWindow::AttachScrollers() BMenuWindow::AttachScrollers()
{ {
// We want to attach a scroller only if there's a menu frame already // We want to attach a scroller only if there's a
// existing. // menu frame already existing.
if (!fMenu || !fMenuFrame) if (!fMenu || !fMenuFrame)
return; return;
if (fUpperScroller || fLowerScroller)
debugger("Scrollers are already attached!");
fMenu->MakeFocus(true); fMenu->MakeFocus(true);
BRect frame = Bounds(); BRect frame = Bounds();
fUpperScroller = new UpperScroller(BRect(0, 0, frame.right, kScrollerHeight));
AddChild(fUpperScroller); if (fUpperScroller == NULL) {
fLowerScroller = new LowerScroller(BRect(0, frame.bottom - kScrollerHeight, frame.right, frame.bottom)); fUpperScroller = new UpperScroller(
AddChild(fLowerScroller); BRect(0, 0, frame.right, kScrollerHeight));
AddChild(fUpperScroller);
}
if (fLowerScroller == NULL) {
fLowerScroller = new LowerScroller(
BRect(0, frame.bottom - kScrollerHeight,
frame.right, frame.bottom));
AddChild(fLowerScroller);
}
fUpperScroller->SetEnabled(false); fUpperScroller->SetEnabled(false);
fLowerScroller->SetEnabled(true); fLowerScroller->SetEnabled(true);