Added keyboard shortcuts escape and delete to style manager

Originally committed to SVN as r924.
This commit is contained in:
Dan Donovan 2007-02-05 19:09:45 +00:00
parent 008d60ba65
commit 56c7891baf
3 changed files with 55 additions and 4 deletions

View File

@ -201,7 +201,7 @@ Please visit http://aegisub.net to download latest version
- Implemented sorting of subtitles by start time. (AMZ)
- Recovered subtitle files are now saved in their own subfolder (customizeable in config.dat). (AMZ)
- Fixed crash with changing font properties via the subtitle edit box when there was a \fs override tag earlier in the line. (AMZ)
- Added shortcut keys (escape to close and delete to delete a style) to style manager. (Dansolo)
= 1.09 beta - 2006.01.16 ===========================

View File

@ -158,6 +158,10 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
LoadCatalog();
LoadCurrentStyles(AssFile::top);
//Set key handlers for lists
StorageList->SetEventHandler(new DialogStyleManagerEvent(this));
CurrentList->SetEventHandler(new DialogStyleManagerEvent(this));
// Select default item
wxString selected_style;
if (_grid) {
@ -661,7 +665,7 @@ void DialogStyleManager::OnStorageDelete (wxCommandEvent &event) {
message += _(" styles?");
}
else message = _("Are you sure you want to delete this style?");
int option = wxMessageBox(message, _("Confirm delete"), wxYES_NO | wxICON_EXCLAMATION , this);
int option = wxMessageBox(message, _("Confirm delete from storage"), wxYES_NO | wxICON_EXCLAMATION , this);
if (option == wxYES) {
AssStyle *temp;
@ -695,7 +699,7 @@ void DialogStyleManager::OnCurrentDelete (wxCommandEvent &event) {
message += _(" styles?");
}
else message = _("Are you sure you want to delete this style?");
int option = wxMessageBox(message, _("Confirm delete"), wxYES_NO | wxICON_EXCLAMATION , this);
int option = wxMessageBox(message, _("Confirm delete from current"), wxYES_NO | wxICON_EXCLAMATION , this);
if (option == wxYES) {
AssStyle *temp;
@ -855,7 +859,6 @@ void DialogStyleManager::OnCurrentMoveDown (wxCommandEvent &event) { MoveStyles(
void DialogStyleManager::OnCurrentMoveBottom (wxCommandEvent &event) { MoveStyles(false,3); }
void DialogStyleManager::OnCurrentSort (wxCommandEvent &event) { MoveStyles(false,4); }
/////////////////
// Move function
void DialogStyleManager::MoveStyles(bool storage, int type) {
@ -997,7 +1000,41 @@ void DialogStyleManager::MoveStyles(bool storage, int type) {
}
//////////////////
// Keydown event
void DialogStyleManager::OnKeyDown(wxKeyEvent &event) {
wxCommandEvent evt;
switch(event.GetKeyCode()) {
case WXK_ESCAPE :
OnClose(evt);
break;
case WXK_DELETE :
if (wxWindow::FindFocus()==StorageList) {
OnStorageDelete(evt);
}
else if (wxWindow::FindFocus()==CurrentList) {
OnCurrentDelete(evt);
}
break;
}
}
//////////////////
// I have no clue
int DialogStyleManager::lastx = -1;
int DialogStyleManager::lasty = -1;
/////////////////////////////////
// DialogStyleManagerEvent stuff
DialogStyleManagerEvent::DialogStyleManagerEvent(DialogStyleManager *ctrl) {
control = ctrl;
}
BEGIN_EVENT_TABLE(DialogStyleManagerEvent, wxEvtHandler)
EVT_KEY_DOWN(DialogStyleManagerEvent::OnKeyDown)
END_EVENT_TABLE()
void DialogStyleManagerEvent::OnKeyDown(wxKeyEvent &event) {
control->OnKeyDown(event); //we need to access controls, so rather than make the controls public...
}

View File

@ -129,6 +129,7 @@ public:
void OnStorageDelete (wxCommandEvent &event);
void OnCurrentDelete (wxCommandEvent &event);
void OnCurrentImport (wxCommandEvent &event);
void OnKeyDown (wxKeyEvent &event);
DECLARE_EVENT_TABLE()
};
@ -166,4 +167,17 @@ enum {
};
/////////////////
// Event handler
class DialogStyleManagerEvent : public wxEvtHandler {
private:
DialogStyleManager *control;
void OnKeyDown(wxKeyEvent &event);
public:
DialogStyleManagerEvent(DialogStyleManager *control);
DECLARE_EVENT_TABLE()
};
#endif