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

Constructor & Destructor Documentation

◆ Listener()

AButton::Listener::Listener ( AButton button)

Definition at line 72 of file AButton.cpp.

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

◆ ~Listener()

AButton::Listener::~Listener ( )

Definition at line 78 of file AButton.cpp.

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

Member Function Documentation

◆ FilterEvent()

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

Definition at line 104 of file AButton.cpp.

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

◆ OnEvent()

void AButton::Listener::OnEvent ( )

Definition at line 83 of file AButton.cpp.

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

Member Data Documentation

◆ mButton

AButton* AButton::Listener::mButton
private

Definition at line 69 of file AButton.cpp.


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