Update of /cvsroot/audacity/audacity-src/src/toolbars
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv6954
Modified Files:
SelectionBar.cpp SelectionBar.h
Log Message:
Capture numeric keystrokes when project rate has the focus. Fixes not being
able to enter a "1" in the edit box.
Index: SelectionBar.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/toolbars/SelectionBar.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SelectionBar.cpp 3 Nov 2006 03:24:44 -0000 1.2
+++ SelectionBar.cpp 20 Nov 2006 00:03:37 -0000 1.3
@@ -42,6 +42,7 @@
#include "SelectionBar.h"
+#include "../AudacityApp.h"
#include "../AudioIO.h"
#include "../AColor.h"
#include "../Prefs.h"
@@ -67,6 +68,7 @@
EVT_COMBOBOX(OnRateID, SelectionBar::OnRate)
EVT_TEXT(OnRateID, SelectionBar::OnRate)
EVT_COMMAND(wxID_ANY, EVT_TIMETEXTCTRL_UPDATED, SelectionBar::OnUpdate)
+ EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, SelectionBar::OnRateCaptureKey)
END_EVENT_TABLE()
SelectionBar::SelectionBar()
@@ -167,6 +169,34 @@
mRateBox->SetValue(wxString::Format(wxT("%d"), (int)mRate));
UpdateRates(); // Must be done _after_ setting value on mRateBox!
+ // We need to capture the SetFocus and KillFocus events to set up
+ // for keyboard capture. On Windows and GTK it's easy since the
+ // combobox is presented as one control to hook into.
+ wxWindow *ctrl = mRateBox;
+
+#if defined(__WXMAC__)
+ // The Mac uses a standard wxTextCtrl for the edit portion and that's
+ // the control that gets the focus events. So we have to find the
+ // textctrl.
+ wxWindowList kids = mRateBox->GetChildren();
+ for (unsigned int i = 0; i < kids.GetCount(); i++) {
+ wxClassInfo *ci = kids[i]->GetClassInfo();
+ if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) {
+ ctrl = kids[i];
+ break;
+ }
+ }
+#endif
+
+ ctrl->Connect(wxEVT_SET_FOCUS,
+ wxFocusEventHandler(SelectionBar::OnRateFocus),
+ NULL,
+ this);
+ ctrl->Connect(wxEVT_KILL_FOCUS,
+ wxFocusEventHandler(SelectionBar::OnRateFocus),
+ NULL,
+ this);
+
mainSizer->Add(mRateBox, 0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
#if __WXMSW__ /* As of wx 2.6.2, wxStaticLine is broken for Windows*/
@@ -394,6 +424,35 @@
mRateBox->SetValue(oldValue);
}
+void SelectionBar::OnRateFocus(wxFocusEvent &event)
+{
+ wxCommandEvent e(EVT_CAPTURE_KEYBOARD);
+
+ if (event.GetEventType() == wxEVT_KILL_FOCUS) {
+ e.SetEventType(EVT_RELEASE_KEYBOARD);
+ }
+ e.SetEventObject(this);
+ GetParent()->GetEventHandler()->ProcessEvent(e);
+
+ Refresh(false);
+}
+
+void SelectionBar::OnRateCaptureKey(wxCommandEvent &event)
+{
+ wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
+ int keyCode = kevent->GetKeyCode();
+
+ // Convert numeric keypad entries.
+ if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) keyCode -=
WXK_NUMPAD0 - '0';
+
+ if (keyCode >= '0' || keyCode <= '9')
+ return;
+
+ event.Skip();
+
+ return;
+}
+
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
//
Index: SelectionBar.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/toolbars/SelectionBar.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- SelectionBar.h 16 Sep 2006 05:54:36 -0000 1.1
+++ SelectionBar.h 20 Nov 2006 00:03:37 -0000 1.2
@@ -71,6 +71,8 @@
void OnLengthRadio(wxCommandEvent &evt);
void OnRate(wxCommandEvent & event);
+ void OnRateFocus(wxFocusEvent &event);
+ void OnRateCaptureKey(wxCommandEvent &event);
void OnSize(wxSizeEvent &evt);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs