Audacity  3.0.3
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 }

◆ ~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
177  mButton->SetAlternateIdx(idx);
178  }
179 }

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:
AButton::HasAlternateImages
bool HasAlternateImages(unsigned idx)
Definition: AButton.cpp:415
AButton::Listener::mButton
AButton * mButton
Definition: AButton.cpp:146
AButton::SetAlternateIdx
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:320
AButton::Listener::OnEvent
void OnEvent()
Definition: AButton.cpp:160
AButton::IsDown
bool IsDown()
Definition: AButton.h:113