Remove callbacks and accelerator keys from FDialogListMenu on closing a dialog window

This commit is contained in:
Markus Gans 2016-07-24 20:18:23 +02:00
parent 7d6d5cf71f
commit 4ba7af7cdc
8 changed files with 56 additions and 21 deletions

View File

@ -1,3 +1,10 @@
2016-07-23 Markus Gans <guru.mail@muenster.de>
* Add missing null pointer check in FOptiAttr before dereferencing
* Remove callbacks and accelerator keys from FDialogListMenu
on closing of a dialog window
* Execute accelerator keys only once
* Improved window focus behavior
2016-07-23 Markus Gans <guru.mail@muenster.de> 2016-07-23 Markus Gans <guru.mail@muenster.de>
* Add a modifier key correction for the linux tty * Add a modifier key correction for the linux tty
* Support to read meta+enter from keyboard * Support to read meta+enter from keyboard

View File

@ -393,17 +393,20 @@ void FApplication::processKeyboardEvent()
&& ! k_press_ev.isAccepted() && ! k_press_ev.isAccepted()
&& ! k_down_ev.isAccepted() ) && ! k_down_ev.isAccepted() )
{ {
bool accpt = false;
// switch to a specific dialog with Meta + 1..9
if ( ! accpt )
accpt = processDialogSwitchAccelerator();
// windows keyboard accelerator // windows keyboard accelerator
FWidget* window = static_cast<FWidget*>(active_window); FWidget* window = static_cast<FWidget*>(active_window);
if ( window ) if ( window && ! accpt )
processAccelerator (window); accpt = processAccelerator (window);
// global keyboard accelerator // global keyboard accelerator
processAccelerator (getRootWidget()); if ( ! accpt )
accpt = processAccelerator (getRootWidget());
// switch to a specific dialog with Meta + 1..9
processDialogSwitchAccelerator();
} }
} // end of else } // end of else
} }
@ -715,7 +718,7 @@ int FApplication::modifierKeyCorrection (int& key_id)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processDialogSwitchAccelerator() bool FApplication::processDialogSwitchAccelerator()
{ {
if ( key >= fc::Fmkey_1 && key <= fc::Fmkey_9 ) if ( key >= fc::Fmkey_1 && key <= fc::Fmkey_9 )
{ {
@ -726,13 +729,18 @@ void FApplication::processDialogSwitchAccelerator()
{ {
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget); FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
sendEvent (dialog_list->at(n-1), &a_ev); sendEvent (dialog_list->at(n-1), &a_ev);
return true;
} }
} }
return false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processAccelerator (FWidget* widget) bool FApplication::processAccelerator (FWidget* widget)
{ {
bool accpt = false;
if ( widget if ( widget
&& widget->accelerator_list && widget->accelerator_list
&& ! widget->accelerator_list->empty() ) && ! widget->accelerator_list->empty() )
@ -750,12 +758,15 @@ void FApplication::processAccelerator (FWidget* widget)
{ {
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget); FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
sendEvent (iter->object, &a_ev); sendEvent (iter->object, &a_ev);
accpt = a_ev.isAccepted();
break; break;
}; };
++iter; ++iter;
} }
} }
return accpt;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -125,8 +125,8 @@ class FApplication : public FWidget
ssize_t readKey(); ssize_t readKey();
void processKeyboardEvent(); void processKeyboardEvent();
int modifierKeyCorrection (int& key); int modifierKeyCorrection (int& key);
void processDialogSwitchAccelerator(); bool processDialogSwitchAccelerator();
void processAccelerator (FWidget*); bool processAccelerator (FWidget*);
void getX11ButtonState (int); void getX11ButtonState (int);
bool parseX11Mouse(); bool parseX11Mouse();
bool parseSGRMouse(); bool parseSGRMouse();

View File

@ -1026,10 +1026,7 @@ void FMenu::onKeyPress (FKeyEvent* ev)
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
activatePrevWindow(); switchToPrevWindow();
raiseWindow (getActiveWindow());
getActiveWindow()->getFocusWidget()->setFocus();
getActiveWindow()->redraw();
} }
if ( statusBar() ) if ( statusBar() )

View File

@ -644,7 +644,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
(*iter)->setSelected(); (*iter)->setSelected();
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget && ! focused_widget->isWindow() )
focused_widget->redraw(); focused_widget->redraw();
(*iter)->openMenu(); (*iter)->openMenu();
@ -820,7 +820,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
(*iter)->setSelected(); (*iter)->setSelected();
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget && ! focused_widget->isWindow() )
focused_widget->redraw(); focused_widget->redraw();
(*iter)->openMenu(); (*iter)->openMenu();

View File

@ -280,6 +280,13 @@ void FMenuItem::createDialogList (FMenu* winmenu)
_METHOD_CALLBACK (this, &FMenuItem::cb_switchToDialog), _METHOD_CALLBACK (this, &FMenuItem::cb_switchToDialog),
dynamic_cast<FWidget::data_ptr>(win) dynamic_cast<FWidget::data_ptr>(win)
); );
win->addCallback
(
"destroy",
_METHOD_CALLBACK (this, &FMenuItem::cb_destroyDialog),
static_cast<FWidget::data_ptr>(win_item)
);
} }
++iter; ++iter;
@ -307,6 +314,19 @@ void FMenuItem::cb_switchToDialog (FWidget*, void* data_ptr)
} }
} }
//----------------------------------------------------------------------
void FMenuItem::cb_destroyDialog (FWidget* widget, void* data_ptr)
{
FDialog* win = static_cast<FDialog*>(widget);
FMenuItem* win_item = static_cast<FMenuItem*>(data_ptr);
if ( win_item && win )
{
win_item->delAccelerator(win);
win_item->delCallback(this);
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processClicked() void FMenuItem::processClicked()
{ {

View File

@ -65,6 +65,7 @@ class FMenuItem : public FWidget
void processDeactivate(); void processDeactivate();
void createDialogList (FMenu*); void createDialogList (FMenu*);
void cb_switchToDialog (FWidget*, void*); void cb_switchToDialog (FWidget*, void*);
void cb_destroyDialog (FWidget*, void*);
virtual void processClicked(); virtual void processClicked();
protected: protected:

View File

@ -396,12 +396,11 @@ void FWindow::switchToPrevWindow()
if ( ! active_window->isActiveWindow() ) if ( ! active_window->isActiveWindow() )
setActiveWindow(active_window); setActiveWindow(active_window);
raiseWindow (active_window); if ( focus_widget && ! focus_widget->isWindow() )
{
if ( focus_widget )
focus_widget->setFocus(); focus_widget->setFocus();
active_window->redraw();
active_window->redraw(); }
} }
} }