obs-studio/UI/menu-button.cpp

35 lines
570 B
C++
Raw Normal View History

#include <QMenu>
#include <QKeyEvent>
#include <QMouseEvent>
#include "menu-button.hpp"
void MenuButton::keyPressEvent(QKeyEvent *event)
{
if (menu()) {
switch (event->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
emit clicked();
return;
case Qt::Key_Down:
case Qt::Key_Space:
showMenu();
return;
}
}
QPushButton::keyPressEvent(event);
}
void MenuButton::mousePressEvent(QMouseEvent *event)
{
if (menu()) {
2022-06-30 10:11:50 -07:00
if (width() - event->x() <= 30)
showMenu();
else
setDown(true);
} else {
QPushButton::mousePressEvent(event);
}
}