Audacity  2.2.2
Public Member Functions | Private Attributes | List of all members
AButton::Listener Class Referencefinal
Inheritance diagram for AButton::Listener:

Public Member Functions

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

Private Attributes

AButtonmButton
 

Detailed Description

Definition at line 54 of file AButton.cpp.

Constructor & Destructor Documentation

AButton::Listener::Listener ( AButton button)

Definition at line 69 of file AButton.cpp.

70 : mButton(button)
71 {
72  wxEvtHandler::AddFilter(this);
73 }
AButton * mButton
Definition: AButton.cpp:66
AButton::Listener::~Listener ( )

Definition at line 75 of file AButton.cpp.

76 {
77  wxEvtHandler::RemoveFilter(this);
78 }

Member Function Documentation

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

Definition at line 101 of file AButton.cpp.

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

Definition at line 80 of file AButton.cpp.

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

Member Data Documentation

AButton* AButton::Listener::mButton
private

Definition at line 66 of file AButton.cpp.


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