Audacity 3.2.0
Public Member Functions | List of all members
BasicMenu::anonymous_namespace{BasicMenu.cpp}::Watcher Struct Reference

Singleton object listens to global wxEvent stream. More...

Inheritance diagram for BasicMenu::anonymous_namespace{BasicMenu.cpp}::Watcher:
[legend]
Collaboration diagram for BasicMenu::anonymous_namespace{BasicMenu.cpp}::Watcher:
[legend]

Public Member Functions

 Watcher ()
 
 ~Watcher ()
 
int FilterEvent (wxEvent &event) override
 

Detailed Description

Singleton object listens to global wxEvent stream.

Definition at line 93 of file BasicMenu.cpp.

Constructor & Destructor Documentation

◆ Watcher()

BasicMenu::anonymous_namespace{BasicMenu.cpp}::Watcher::Watcher ( )
inline

Definition at line 95 of file BasicMenu.cpp.

96 {
97 wxEvtHandler::AddFilter( this );
98 }

◆ ~Watcher()

BasicMenu::anonymous_namespace{BasicMenu.cpp}::Watcher::~Watcher ( )
inline

Definition at line 100 of file BasicMenu.cpp.

101 {
102 wxEvtHandler::RemoveFilter( this );
103 }

Member Function Documentation

◆ FilterEvent()

int BasicMenu::anonymous_namespace{BasicMenu.cpp}::Watcher::FilterEvent ( wxEvent &  event)
inlineoverride

Definition at line 105 of file BasicMenu.cpp.

106 {
107 using namespace Journal::Events;
108
109 // Record something only if we are recording events, this is a menu
110 // event, there is an outstanding popup menu, and that or a descendant
111 // is the event object
112 auto pObj = event.GetEventObject();
113 if (!(IsWatching() &&
114 event.GetEventType() == wxEVT_MENU &&
115 !sMenuStack.empty() &&
116 ContainsMenu( sMenuStack.back(), pObj ) ))
117 return Event_Skip;
118
119 // Find a path identifying the object
120 auto pPath = FindPathName( *static_cast<wxMenu*>(pObj), event.GetId() );
121 if ( !pPath ) {
123 return Event_Skip;
124 }
125
126 // Write a representation to the journal.
127 // Write names, not numerical ids, so the journal is not
128 // fragile if the assignment of ids to commands changes.
129 pPath->insert( pPath->begin(), JournalCode );
130 Journal::Output( *pPath );
131 sHandledEvent = true;
132
133 return Event_Skip;
134 }
bool ContainsMenu(const Menus &menus, void *pObj)
Definition: BasicMenu.cpp:52
std::optional< wxArrayStringEx > FindPathName(wxMenu &theMenu, int id)
Definition: BasicMenu.cpp:59
void FailedEventSerialization()
void Output(const wxString &string)

References BasicMenu::anonymous_namespace{BasicMenu.cpp}::ContainsMenu(), Journal::Events::FailedEventSerialization(), BasicMenu::anonymous_namespace{BasicMenu.cpp}::FindPathName(), Journal::Events::IsWatching(), JournalCode, Journal::Output(), BasicMenu::anonymous_namespace{BasicMenu.cpp}::sHandledEvent, and BasicMenu::anonymous_namespace{BasicMenu.cpp}::sMenuStack.

Here is the call graph for this function:

The documentation for this struct was generated from the following file: