mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-20 22:30:05 +02:00
Open popup menu under icon when using context menu key
This commit is contained in:
parent
c3c458e3fa
commit
c9cde48f21
@ -190,6 +190,7 @@ enum {
|
|||||||
BEGIN_EVENT_TABLE(Meter, wxPanel)
|
BEGIN_EVENT_TABLE(Meter, wxPanel)
|
||||||
EVT_TIMER(OnMeterUpdateID, Meter::OnMeterUpdate)
|
EVT_TIMER(OnMeterUpdateID, Meter::OnMeterUpdate)
|
||||||
EVT_MOUSE_EVENTS(Meter::OnMouse)
|
EVT_MOUSE_EVENTS(Meter::OnMouse)
|
||||||
|
EVT_KEY_DOWN(Meter::OnKeyDown)
|
||||||
EVT_ERASE_BACKGROUND(Meter::OnErase)
|
EVT_ERASE_BACKGROUND(Meter::OnErase)
|
||||||
EVT_PAINT(Meter::OnPaint)
|
EVT_PAINT(Meter::OnPaint)
|
||||||
EVT_SIZE(Meter::OnSize)
|
EVT_SIZE(Meter::OnSize)
|
||||||
@ -665,10 +666,12 @@ void Meter::OnMouse(wxMouseEvent &evt)
|
|||||||
|
|
||||||
menu->Append(OnPreferencesID, _("Preferences..."));
|
menu->Append(OnPreferencesID, _("Preferences..."));
|
||||||
|
|
||||||
if (evt.RightDown())
|
if (evt.RightDown()) {
|
||||||
PopupMenu(menu, evt.m_x, evt.m_y);
|
ShowMenu(evt.GetPosition());
|
||||||
else
|
}
|
||||||
PopupMenu(menu, mIconRect.x + 1, mIconRect.y + mIconRect.height + 1);
|
else {
|
||||||
|
ShowMenu(wxPoint(mIconRect.x + 1, mIconRect.y + mIconRect.height + 1));
|
||||||
|
}
|
||||||
|
|
||||||
delete menu;
|
delete menu;
|
||||||
}
|
}
|
||||||
@ -687,7 +690,15 @@ void Meter::OnMouse(wxMouseEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meter::SetStyle(Meter::Style newStyle)
|
void Meter::OnKeyDown(wxKeyEvent &evt)
|
||||||
|
{
|
||||||
|
if (evt.GetKeyCode() == WXK_WINDOWS_MENU)
|
||||||
|
{
|
||||||
|
ShowMenu(wxPoint(mIconRect.x + 1, mIconRect.y + mIconRect.height + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Meter::SetStyle(Style newStyle)
|
||||||
{
|
{
|
||||||
if (mStyle != newStyle && mDesiredStyle == AutomaticStereo)
|
if (mStyle != newStyle && mDesiredStyle == AutomaticStereo)
|
||||||
{
|
{
|
||||||
@ -1775,9 +1786,29 @@ void Meter::RestoreState(void *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pop-up menu handlers
|
// Pop-up menu
|
||||||
//
|
//
|
||||||
|
|
||||||
|
void Meter::ShowMenu(const wxPoint & pos)
|
||||||
|
{
|
||||||
|
wxMenu *menu = new wxMenu();
|
||||||
|
// Note: these should be kept in the same order as the enum
|
||||||
|
if (mIsInput) {
|
||||||
|
wxMenuItem *mi;
|
||||||
|
if (mMonitoring)
|
||||||
|
mi = menu->Append(OnMonitorID, _("Stop Monitoring"));
|
||||||
|
else
|
||||||
|
mi = menu->Append(OnMonitorID, _("Start Monitoring"));
|
||||||
|
mi->Enable(!mActive || mMonitoring);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->Append(OnPreferencesID, _("Preferences..."));
|
||||||
|
|
||||||
|
PopupMenu(menu, pos);
|
||||||
|
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
void Meter::OnMonitor(wxCommandEvent & WXUNUSED(event))
|
void Meter::OnMonitor(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
StartMonitoring();
|
StartMonitoring();
|
||||||
|
@ -183,6 +183,7 @@ class Meter : public wxPanel
|
|||||||
void OnPaint(wxPaintEvent &evt);
|
void OnPaint(wxPaintEvent &evt);
|
||||||
void OnSize(wxSizeEvent &evt);
|
void OnSize(wxSizeEvent &evt);
|
||||||
void OnMouse(wxMouseEvent &evt);
|
void OnMouse(wxMouseEvent &evt);
|
||||||
|
void OnKeyDown(wxKeyEvent &evt);
|
||||||
|
|
||||||
void OnAudioIOStatus(wxCommandEvent &evt);
|
void OnAudioIOStatus(wxCommandEvent &evt);
|
||||||
|
|
||||||
@ -197,9 +198,9 @@ class Meter : public wxPanel
|
|||||||
wxFont GetFont() const;
|
wxFont GetFont() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pop-up menu handlers
|
// Pop-up menu
|
||||||
//
|
//
|
||||||
|
void ShowMenu(const wxPoint & pos);
|
||||||
void OnMonitor(wxCommandEvent &evt);
|
void OnMonitor(wxCommandEvent &evt);
|
||||||
void OnPreferences(wxCommandEvent &evt);
|
void OnPreferences(wxCommandEvent &evt);
|
||||||
void OnMeterPrefsUpdated(wxCommandEvent &evt);
|
void OnMeterPrefsUpdated(wxCommandEvent &evt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user