MCPcopy Create free account
hub / github.com/audacity/audacity / TextualCommandType

Function TextualCommandType

src/JournalEvents.cpp:290–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288
289template<typename Event = wxCommandEvent, typename EventType >
290static Type TextualCommandType( EventType type, const wxString &code ){
291 // Writes a window identifier to the journal and a string
292 const auto serialize =
293 []( const Event &event ) {
294 auto result = WindowEventSerialization( event );
295 if ( result )
296 result->push_back( event.GetString() );
297 return result;
298 };
299
300 const auto deserialize =
301 []( wxEventType type, const wxArrayStringEx &components ) {
302 std::unique_ptr< Event > result;
303 if ( components.size() == 2 ) {
304 if ( auto pWindow = WindowPaths::FindByPath( components[0] ) ) {
305 auto value = components[1];
306 result = std::make_unique< Event >(
307 type, pWindow->GetId() );
308 result->SetEventObject( pWindow );
309 result->SetString( value );
310 // Also change the state of the control before the event is
311 // processed.
312 if ( auto pCtrl = dynamic_cast<wxTextEntry*>( pWindow ) ) {
313 // Generic validator calls the SetValue() member function,
314 // which generates an event for this type of control, but we
315 // don't want that. So use ChangeValue() instead
316 pCtrl->ChangeValue( value );
317 }
318 else {
319 // This class handles the most common control types.
320 wxGenericValidator validator( &value );
321 validator.SetWindow( pWindow );
322 validator.TransferToWindow();
323 }
324 }
325 }
326 return result;
327 };
328
329 return Type{ type, code, serialize, deserialize };
330}
331
332const Types &TypeCatalog()
333{

Callers 1

JournalEvents.cppFile · 0.85

Calls 9

WindowEventSerializationFunction · 0.85
FindByPathFunction · 0.85
GetIdMethod · 0.80
SetStringMethod · 0.80
SetWindowMethod · 0.80
push_backMethod · 0.45
GetStringMethod · 0.45
sizeMethod · 0.45
TransferToWindowMethod · 0.45

Tested by

no test coverage detected