1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-23 16:08:07 +02:00

Bug1252 more: click buttons don't steal focus, ctrl+f6 still works

This commit is contained in:
Paul Licameli 2016-06-23 16:35:18 -04:00
parent 001e3af9cb
commit 48414d6e61
3 changed files with 20 additions and 0 deletions

View File

@ -2751,6 +2751,8 @@ void AudacityProject::OnSetRightSelection()
void AudacityProject::NextFrame()
{
auto temp = AButton::TemporarilyAllowFocus();
switch( GetFocusedFrame() )
{
case TopDockHasFocus:
@ -2780,6 +2782,8 @@ void AudacityProject::NextFrame()
void AudacityProject::PrevFrame()
{
auto temp = AButton::TemporarilyAllowFocus();
switch( GetFocusedFrame() )
{
case BotDockHasFocus:

View File

@ -365,6 +365,8 @@ void AButton::OnSize(wxSizeEvent & WXUNUSED(event))
Refresh(false);
}
bool AButton::s_AcceptsFocus{ false };
bool AButton::HasAlternateImages(unsigned idx)
{
if (mImages.size() <= idx)

View File

@ -56,6 +56,9 @@ class AButton final : public wxWindow {
virtual ~ AButton();
bool AcceptsFocus() const override { return s_AcceptsFocus; }
bool AcceptsFocusFromKeyboard() const override { return true; }
// Associate a set of four images (button up, highlight, button down,
// disabled) with one nondefault state of the button
void SetAlternateImages(unsigned idx,
@ -133,6 +136,17 @@ class AButton final : public wxWindow {
void UseDisabledAsDownHiliteImage(bool flag);
private:
static bool s_AcceptsFocus;
struct Resetter { void operator () (bool *p) const { if(p) *p = false; } };
using TempAllowFocus = std::unique_ptr<bool, Resetter>;
public:
static TempAllowFocus TemporarilyAllowFocus() {
s_AcceptsFocus = true;
return std::move(TempAllowFocus{ &s_AcceptsFocus });
}
private:
bool HasAlternateImages(unsigned idx);