Merge r3999 to trunk, updates #566.
Also, 4000 GET. Originally committed to SVN as r4000.
This commit is contained in:
parent
80fdea74e6
commit
f1fa69d528
2 changed files with 23 additions and 68 deletions
|
@ -1063,7 +1063,7 @@ void DialogOptions::OnEditHotkey(wxCommandEvent &event) {
|
|||
int oldFlags = curKey->flags;
|
||||
|
||||
// Open dialog
|
||||
DialogInputHotkey input(curKey,Shortcuts->GetItemText(sel),Shortcuts);
|
||||
DialogInputHotkey input(this, curKey, Shortcuts->GetItemText(sel), Shortcuts);
|
||||
input.ShowModal();
|
||||
|
||||
// Update stuff if it changed
|
||||
|
@ -1160,44 +1160,31 @@ void DialogOptions::OnDefaultAllHotkey(wxCommandEvent &event) {
|
|||
/// @param name
|
||||
/// @param shorts
|
||||
///
|
||||
DialogInputHotkey::DialogInputHotkey(HotkeyType *_key,wxString name,wxListView *shorts)
|
||||
: wxDialog(NULL, -1, _("Press Key"), wxDefaultPosition, wxSize(200,50), wxCAPTION | wxWANTS_CHARS , _T("Press key"))
|
||||
DialogInputHotkey::DialogInputHotkey(wxWindow *parent, HotkeyType *_key, wxString name, wxListView *shorts)
|
||||
: wxDialog(parent, -1, _("Press Key"), wxDefaultPosition, wxSize(200,50), wxCAPTION | wxWANTS_CHARS , _T("Press key"))
|
||||
{
|
||||
// Key
|
||||
key = _key;
|
||||
shortcuts = shorts;
|
||||
|
||||
// Text
|
||||
wxStaticText *text = new wxStaticText(this,-1,wxString::Format(_("Press key to bind to \"%s\" or Esc to cancel."), name.c_str()));
|
||||
|
||||
// Key capturer
|
||||
capture = new CaptureKey(this);
|
||||
wxButton *cancel_button = new wxButton(this, wxID_CANCEL);
|
||||
cancel_button->Connect(wxEVT_KEY_DOWN, (wxObjectEventFunction)&DialogInputHotkey::OnKeyDown, 0, this);
|
||||
|
||||
// Main sizer
|
||||
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
MainSizer->Add(text,1,wxALL,5);
|
||||
MainSizer->Add(new wxStaticText(this,-1,wxString::Format(_("Press key to bind to \"%s\" or Esc to cancel."), name.c_str())), 0, wxALL, 12);
|
||||
MainSizer->Add(cancel_button, 0, wxALIGN_CENTER|wxALL&~wxTOP, 12);
|
||||
MainSizer->SetSizeHints(this);
|
||||
SetSizer(MainSizer);
|
||||
CentreOnParent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Capturer constructor
|
||||
/// @param _parent
|
||||
///
|
||||
CaptureKey::CaptureKey(DialogInputHotkey *_parent)
|
||||
: wxTextCtrl(_parent,-1,_T(""),wxDefaultPosition,wxSize(0,0),wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB)
|
||||
{
|
||||
parent = _parent;
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// Input event table
|
||||
BEGIN_EVENT_TABLE(CaptureKey,wxTextCtrl)
|
||||
EVT_KEY_DOWN(CaptureKey::OnKeyDown)
|
||||
EVT_KILL_FOCUS(CaptureKey::OnLoseFocus)
|
||||
BEGIN_EVENT_TABLE(DialogInputHotkey,wxDialog)
|
||||
EVT_KEY_DOWN(DialogInputHotkey::OnKeyDown)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -1206,10 +1193,10 @@ END_EVENT_TABLE()
|
|||
/// @param event
|
||||
/// @return
|
||||
///
|
||||
void CaptureKey::OnKeyDown(wxKeyEvent &event) {
|
||||
void DialogInputHotkey::OnKeyDown(wxKeyEvent &event) {
|
||||
// Get key
|
||||
int keycode = event.GetKeyCode();
|
||||
if (keycode == WXK_ESCAPE) parent->EndModal(0);
|
||||
if (keycode == WXK_ESCAPE) EndModal(0);
|
||||
else if (keycode != WXK_SHIFT && keycode != WXK_CONTROL && keycode != WXK_ALT) {
|
||||
// Get modifier
|
||||
int mod = 0;
|
||||
|
@ -1226,32 +1213,22 @@ void CaptureKey::OnKeyDown(wxKeyEvent &event) {
|
|||
if (dup) {
|
||||
int result = wxMessageBox(wxString::Format(_("The hotkey %s is already mapped to %s. If you proceed, that hotkey will be cleared. Proceed?"),dup->GetText().c_str(),dup->origName.c_str()),_("Hotkey conflict"),wxYES_NO | wxICON_EXCLAMATION);
|
||||
if (result == wxNO) {
|
||||
parent->EndModal(0);
|
||||
EndModal(0);
|
||||
return;
|
||||
}
|
||||
dup->keycode = 0;
|
||||
dup->flags = 0;
|
||||
int item = parent->shortcuts->FindItem(-1,wxPtrToUInt(dup));
|
||||
if (item != -1) parent->shortcuts->SetItem(item,1,dup->GetText());
|
||||
int item = shortcuts->FindItem(-1,wxPtrToUInt(dup));
|
||||
if (item != -1) shortcuts->SetItem(item,1,dup->GetText());
|
||||
}
|
||||
|
||||
// Set keycode
|
||||
parent->key->keycode = keycode;
|
||||
parent->key->flags = mod;
|
||||
key->keycode = keycode;
|
||||
key->flags = mod;
|
||||
|
||||
// End dialogue
|
||||
parent->EndModal(0);
|
||||
EndModal(0);
|
||||
}
|
||||
else event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Keep focus
|
||||
/// @param event
|
||||
///
|
||||
void CaptureKey::OnLoseFocus(wxFocusEvent &event) {
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -161,26 +161,6 @@ public:
|
|||
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class CaptureKey
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class CaptureKey : public wxTextCtrl {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
DialogInputHotkey *parent;
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
void OnLoseFocus(wxFocusEvent &event);
|
||||
|
||||
public:
|
||||
CaptureKey(DialogInputHotkey *parent);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class DialogInputHotkey
|
||||
|
@ -188,12 +168,6 @@ public:
|
|||
///
|
||||
/// DOCME
|
||||
class DialogInputHotkey : public wxDialog {
|
||||
friend class CaptureKey;
|
||||
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
CaptureKey *capture;
|
||||
|
||||
/// DOCME
|
||||
HotkeyType *key;
|
||||
|
@ -201,8 +175,12 @@ private:
|
|||
/// DOCME
|
||||
wxListView *shortcuts;
|
||||
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
|
||||
public:
|
||||
DialogInputHotkey(HotkeyType *key,wxString name,wxListView *Shortcuts);
|
||||
DialogInputHotkey(wxWindow *parent, HotkeyType *key, wxString name, wxListView *Shortcuts);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue