Chat-O-Matic/libs/libinterface/MenuButton.cpp
Jaidyn Ann 33ad4d8acf More scalable ToolButton
Replaces libinterface's ToolButton, a custom button that can display
a pop-up menu on click (along with a custom image). It didn't scale well
with different themes and font-sizes compared to BButtons― which
ToolButton is supposed to look like to begin with.

A BButton-derived class is used instead, so these buttons look more
in-place among other buttons.
2021-07-23 23:43:42 -05:00

55 lines
792 B
C++

/*
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "MenuButton.h"
#include <PopUpMenu.h>
MenuButton::MenuButton(const char* name, const char* label, BMessage* message)
:
BButton(name, BString(label).Append(""), message),
fMenu(NULL)
{
}
void
MenuButton::MouseDown(BPoint where)
{
BButton::MouseDown(where);
if (fMenu != NULL)
fMenu->Go(ConvertToScreen(where), true, true, true);
}
void
MenuButton::MouseUp(BPoint where)
{
BButton::MouseUp(where);
SetValue(B_CONTROL_OFF);
}
void
MenuButton::MouseMoved(BPoint where, uint32 code, const BMessage* dragMsg)
{
}
BPopUpMenu*
MenuButton::Menu()
{
return fMenu;
}
void
MenuButton::SetMenu(BPopUpMenu* menu)
{
fMenu = menu;
}