Switch to a specific dialog with meta + 1..9

This commit is contained in:
Markus Gans 2016-07-16 20:39:38 +02:00
parent ef201a1a33
commit 75b6ac477e
7 changed files with 188 additions and 124 deletions

View File

@ -1,3 +1,7 @@
2016-07-16 Markus Gans <guru.mail@muenster.de>
* Switch to a specific dialog with meta key + 1..9
* Add more meta key escape sequences (for putty)
2016-07-14 Markus Gans <guru.mail@muenster.de> 2016-07-14 Markus Gans <guru.mail@muenster.de>
* Adding a dialog list with the entries in the chronological * Adding a dialog list with the entries in the chronological
order of the generation order of the generation

View File

@ -399,6 +399,9 @@ void FApplication::processKeyboardEvent()
// global keyboard accelerator // global keyboard accelerator
processAccelerator (getRootWidget()); processAccelerator (getRootWidget());
// switch to a specific dialog with Meta + 1..9
processDialogSwitchAccelerator();
} }
} // end of else } // end of else
} }
@ -428,6 +431,22 @@ void FApplication::processKeyboardEvent()
} }
} }
//----------------------------------------------------------------------
void FApplication::processDialogSwitchAccelerator()
{
if ( key >= fc::Fmkey_1 && key <= fc::Fmkey_9 )
{
int n = key - fc::Fmkey_0;
int s = dialog_list->size();
if ( s > 0 && s >= n )
{
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
sendEvent (dialog_list->at(n-1), &a_ev);
}
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processAccelerator (FWidget* widget) void FApplication::processAccelerator (FWidget* widget)
{ {
@ -1346,7 +1365,7 @@ void FApplication::processCloseWidget()
widgetList::iterator iter; widgetList::iterator iter;
iter = close_widget->begin(); iter = close_widget->begin();
while ( iter != close_widget->end() ) while ( iter != close_widget->end() && *iter )
{ {
delete *iter; delete *iter;
++iter; ++iter;

View File

@ -124,6 +124,7 @@ class FApplication : public FWidget
bool KeyPressed(); bool KeyPressed();
ssize_t readKey(); ssize_t readKey();
void processKeyboardEvent(); void processKeyboardEvent();
void processDialogSwitchAccelerator();
void processAccelerator (FWidget*); void processAccelerator (FWidget*);
void getX11ButtonState (int); void getX11ButtonState (int);
bool parseX11Mouse(); bool parseX11Mouse();

View File

@ -801,6 +801,22 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
} }
} }
//----------------------------------------------------------------------
void FDialog::onAccel (FAccelEvent*)
{
if ( ! this->isHiddenWindow() && ! this->isActiveWindow() )
{
FWindow::setActiveWindow(this);
FWidget* focus_widget = this->getFocusWidget();
FWindow::raiseWindow (this);
if ( focus_widget )
focus_widget->setFocus();
this->redraw();
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowActive (FEvent*) void FDialog::onWindowActive (FEvent*)
{ {

View File

@ -88,6 +88,7 @@ class FDialog : public FWindow
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*); void onMouseDoubleClick (FMouseEvent*);
void onAccel (FAccelEvent*);
void onWindowActive (FEvent*); void onWindowActive (FEvent*);
void onWindowInactive (FEvent*); void onWindowInactive (FEvent*);
void onWindowRaised (FEvent*); void onWindowRaised (FEvent*);

View File

@ -196,27 +196,49 @@ metakeymap;
static metakeymap Fmetakey[] = static metakeymap Fmetakey[] =
{ {
{ fc::Fmkey_ic , "\033[2;3~" }, // M-insert { fc::Fmkey_ic , "\033[2;3~" }, // M-insert
{ fc::Fmkey_ic , "\033\033[2~" }, // M-insert
{ fc::Fmkey_dc , "\033[3;3~" }, // M-delete { fc::Fmkey_dc , "\033[3;3~" }, // M-delete
{ fc::Fmkey_dc , "\033\033[3~" }, // M-delete
{ fc::Fmkey_home , "\033[1;3H" }, // M-home { fc::Fmkey_home , "\033[1;3H" }, // M-home
{ fc::Fmkey_home , "\033\033[1~" }, // M-home
{ fc::Fmkey_end , "\033[1;3F" }, // M-end { fc::Fmkey_end , "\033[1;3F" }, // M-end
{ fc::Fmkey_end , "\033\033[4~" }, // M-end
{ fc::Fmkey_ppage , "\033[5;3~" }, // M-prev-page { fc::Fmkey_ppage , "\033[5;3~" }, // M-prev-page
{ fc::Fmkey_ppage , "\033\033[5~" }, // M-prev-page
{ fc::Fmkey_npage , "\033[6;3~" }, // M-next-page { fc::Fmkey_npage , "\033[6;3~" }, // M-next-page
{ fc::Fmkey_npage , "\033\033[6~" }, // M-next-page
{ fc::Fmkey_f1 , "\033[1;3P" }, // M-f1 { fc::Fmkey_f1 , "\033[1;3P" }, // M-f1
{ fc::Fmkey_f1 , "\033\033[11~"}, // M-f1
{ fc::Fmkey_f2 , "\033[1;3Q" }, // M-f2 { fc::Fmkey_f2 , "\033[1;3Q" }, // M-f2
{ fc::Fmkey_f2 , "\033\033[12~"}, // M-f2
{ fc::Fmkey_f3 , "\033[1;3R" }, // M-f3 { fc::Fmkey_f3 , "\033[1;3R" }, // M-f3
{ fc::Fmkey_f3 , "\033\033[13~"}, // M-f3
{ fc::Fmkey_f4 , "\033[1;3S" }, // M-f4 { fc::Fmkey_f4 , "\033[1;3S" }, // M-f4
{ fc::Fmkey_f4 , "\033\033[14~"}, // M-f4
{ fc::Fmkey_f5 , "\033[15;3~" }, // M-f5 { fc::Fmkey_f5 , "\033[15;3~" }, // M-f5
{ fc::Fmkey_f5 , "\033\033[15~"}, // M-f5
{ fc::Fmkey_f6 , "\033[17;3~" }, // M-f6 { fc::Fmkey_f6 , "\033[17;3~" }, // M-f6
{ fc::Fmkey_f6 , "\033\033[17~"}, // M-f6
{ fc::Fmkey_f7 , "\033[18;3~" }, // M-f7 { fc::Fmkey_f7 , "\033[18;3~" }, // M-f7
{ fc::Fmkey_f7 , "\033\033[18~"}, // M-f7
{ fc::Fmkey_f8 , "\033[19;3~" }, // M-f8 { fc::Fmkey_f8 , "\033[19;3~" }, // M-f8
{ fc::Fmkey_f8 , "\033\033[19~"}, // M-f8
{ fc::Fmkey_f9 , "\033[20;3~" }, // M-f9 { fc::Fmkey_f9 , "\033[20;3~" }, // M-f9
{ fc::Fmkey_f9 , "\033\033[20~"}, // M-f9
{ fc::Fmkey_f10 , "\033[21;3~" }, // M-f10 { fc::Fmkey_f10 , "\033[21;3~" }, // M-f10
{ fc::Fmkey_f10 , "\033\033[21~"}, // M-f10
{ fc::Fmkey_f11 , "\033[23;3~" }, // M-f11 { fc::Fmkey_f11 , "\033[23;3~" }, // M-f11
{ fc::Fmkey_f11 , "\033\033[23~"}, // M-f11
{ fc::Fmkey_f12 , "\033[24;3~" }, // M-f12 { fc::Fmkey_f12 , "\033[24;3~" }, // M-f12
{ fc::Fmkey_f12 , "\033\033[24~"}, // M-f12
{ fc::Fmkey_up , "\033[1;3A" }, // M-up { fc::Fmkey_up , "\033[1;3A" }, // M-up
{ fc::Fmkey_up , "\033\033[A" }, // M-up
{ fc::Fmkey_down , "\033[1;3B" }, // M-down { fc::Fmkey_down , "\033[1;3B" }, // M-down
{ fc::Fmkey_down , "\033\033[B" }, // M-down
{ fc::Fmkey_right , "\033[1;3C" }, // M-right { fc::Fmkey_right , "\033[1;3C" }, // M-right
{ fc::Fmkey_right , "\033\033[C" }, // M-right
{ fc::Fmkey_left , "\033[1;3D" }, // M-left { fc::Fmkey_left , "\033[1;3D" }, // M-left
{ fc::Fmkey_left , "\033\033[D" }, // M-left
{ fc::Fmkey_sic , "\033[2;4~" }, // shift-M-insert { fc::Fmkey_sic , "\033[2;4~" }, // shift-M-insert
{ fc::Fmkey_sdc , "\033[3;4~" }, // shift-M-delete { fc::Fmkey_sdc , "\033[3;4~" }, // shift-M-delete
{ fc::Fmkey_shome , "\033[1;4H" }, // shift-M-home { fc::Fmkey_shome , "\033[1;4H" }, // shift-M-home

View File

@ -258,20 +258,22 @@ void FMenuItem::createDialogList (FMenu* winmenu)
if ( dialog_list && ! dialog_list->empty() ) if ( dialog_list && ! dialog_list->empty() )
{ {
widgetList::const_iterator iter; widgetList::const_iterator iter, begin;
iter = dialog_list->begin(); iter = begin = dialog_list->begin();
while ( iter != dialog_list->end() ) while ( iter != dialog_list->end() && *iter )
{
if ( *iter && (*iter)->isDialog() )
{ {
FDialog* win = dynamic_cast<FDialog*>(*iter); FDialog* win = dynamic_cast<FDialog*>(*iter);
if ( win ) if ( win )
{ {
int n = std::distance(begin, iter);
FString win_title = win->getText(); FString win_title = win->getText();
FMenuItem* win_item = new FMenuItem (win_title, winmenu); FMenuItem* win_item = new FMenuItem (win_title, winmenu);
if ( n < 9 )
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
win_item->addCallback win_item->addCallback
( (
"clicked", "clicked",
@ -279,7 +281,6 @@ void FMenuItem::createDialogList (FMenu* winmenu)
dynamic_cast<FWidget::data_ptr>(win) dynamic_cast<FWidget::data_ptr>(win)
); );
} }
}
++iter; ++iter;
} }