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 134 of file AButton.cpp.

Constructor & Destructor Documentation

◆ Listener()

AButton::Listener::Listener ( AButton button)

Definition at line 149 of file AButton.cpp.

150: mButton(button)
151{
152 wxEvtHandler::AddFilter(this);
153}
AButton * mButton
Definition: AButton.cpp:146

◆ ~Listener()

AButton::Listener::~Listener ( )

Definition at line 155 of file AButton.cpp.

156{
157 wxEvtHandler::RemoveFilter(this);
158}

Member Function Documentation

◆ FilterEvent()

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

Definition at line 181 of file AButton.cpp.

182{
183 if (event.GetEventType() == wxEVT_KEY_DOWN ||
184 event.GetEventType() == wxEVT_KEY_UP)
185 OnEvent();
186 else if (event.GetEventType() == wxEVT_SET_FOCUS)
187 // A modal dialog might have eaten the modifier key-up with its own
188 // filter before we saw it; this is adequate to fix the button image
189 // when the dialog disappears.
190 OnEvent();
191 return Event_Skip;
192}

◆ OnEvent()

void AButton::Listener::OnEvent ( )

Definition at line 160 of file AButton.cpp.

161{
162 if (!mButton->IsDown())
163 {
164 int idx = 0;
165 // Ignore the event, consult key states. One modifier key might
166 // have gone up but another remained down.
167 // Note that CMD (or CTRL) takes precedence over Shift if both are down
168 // and alternates are defined for both
169 // see also AButton::OnMouseEvent()
170 if (wxGetKeyState(WXK_CONTROL) && mButton->HasAlternateImages(2))
171 idx = 2;
172 else if (wxGetKeyState(WXK_SHIFT) && mButton->HasAlternateImages(1))
173 idx = 1;
174
175 // Turn e.g. the "Play" button into a "Loop" button
176 // or "Cut Preview" button
178 }
179}
bool IsDown()
Definition: AButton.h:113
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:320
bool HasAlternateImages(unsigned idx)
Definition: AButton.cpp:415

Member Data Documentation

◆ mButton

AButton* AButton::Listener::mButton
private

Definition at line 146 of file AButton.cpp.


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