1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01: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

@@ -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);