Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
AButton::Listener Class Referencefinal
Inheritance diagram for AButton::Listener:
[legend]
Collaboration diagram for AButton::Listener:
[legend]

Public Member Functions

 Listener (AButton *button)
 
 ~Listener ()
 
int FilterEvent (wxEvent &event) override
 
void OnEvent ()
 

Private Attributes

AButtonmButton
 

Detailed Description

Definition at line 58 of file AButton.cpp.

Constructor & Destructor Documentation

◆ Listener()

AButton::Listener::Listener ( AButton button)

Definition at line 73 of file AButton.cpp.

74: mButton(button)
75{
76 wxEvtHandler::AddFilter(this);
77}
AButton * mButton
Definition: AButton.cpp:70

◆ ~Listener()

AButton::Listener::~Listener ( )

Definition at line 79 of file AButton.cpp.

80{
81 wxEvtHandler::RemoveFilter(this);
82}

Member Function Documentation

◆ FilterEvent()

int AButton::Listener::FilterEvent ( wxEvent &  event)
override

Definition at line 105 of file AButton.cpp.

106{
107 if (event.GetEventType() == wxEVT_KEY_DOWN ||
108 event.GetEventType() == wxEVT_KEY_UP)
109 OnEvent();
110 else if (event.GetEventType() == wxEVT_SET_FOCUS)
111 // A modal dialog might have eaten the modifier key-up with its own
112 // filter before we saw it; this is adequate to fix the button image
113 // when the dialog disappears.
114 OnEvent();
115 return Event_Skip;
116}

◆ OnEvent()

void AButton::Listener::OnEvent ( )

Definition at line 84 of file AButton.cpp.

85{
86 if (!mButton->IsDown())
87 {
88 int idx = 0;
89 // Ignore the event, consult key states. One modifier key might
90 // have gone up but another remained down.
91 // Note that CMD (or CTRL) takes precedence over Shift if both are down
92 // and alternates are defined for both
93 // see also AButton::OnMouseEvent()
94 if (wxGetKeyState(WXK_CONTROL) && mButton->HasAlternateImages(2))
95 idx = 2;
96 else if (wxGetKeyState(WXK_SHIFT) && mButton->HasAlternateImages(1))
97 idx = 1;
98
99 // Turn e.g. the "Play" button into a "Loop" button
100 // or "Cut Preview" button
102 }
103}
bool HasAlternateImages(unsigned idx) const
Definition: AButton.cpp:465
bool IsDown()
Definition: AButton.h:227
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:287

Member Data Documentation

◆ mButton

AButton* AButton::Listener::mButton
private

Definition at line 70 of file AButton.cpp.


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