Remove callbacks and accelerator keys from FDialogListMenu on closing a dialog window
This commit is contained in:
parent
7d6d5cf71f
commit
4ba7af7cdc
|
@ -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>
|
||||
* Add a modifier key correction for the linux tty
|
||||
* Support to read meta+enter from keyboard
|
||||
|
|
29
src/fapp.cpp
29
src/fapp.cpp
|
@ -393,17 +393,20 @@ void FApplication::processKeyboardEvent()
|
|||
&& ! k_press_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
|
||||
FWidget* window = static_cast<FWidget*>(active_window);
|
||||
|
||||
if ( window )
|
||||
processAccelerator (window);
|
||||
if ( window && ! accpt )
|
||||
accpt = processAccelerator (window);
|
||||
|
||||
// global keyboard accelerator
|
||||
processAccelerator (getRootWidget());
|
||||
|
||||
// switch to a specific dialog with Meta + 1..9
|
||||
processDialogSwitchAccelerator();
|
||||
if ( ! accpt )
|
||||
accpt = processAccelerator (getRootWidget());
|
||||
}
|
||||
} // 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 )
|
||||
{
|
||||
|
@ -726,13 +729,18 @@ void FApplication::processDialogSwitchAccelerator()
|
|||
{
|
||||
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
|
||||
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
|
||||
&& widget->accelerator_list
|
||||
&& ! widget->accelerator_list->empty() )
|
||||
|
@ -750,12 +758,15 @@ void FApplication::processAccelerator (FWidget* widget)
|
|||
{
|
||||
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
|
||||
sendEvent (iter->object, &a_ev);
|
||||
accpt = a_ev.isAccepted();
|
||||
break;
|
||||
};
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
return accpt;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -125,8 +125,8 @@ class FApplication : public FWidget
|
|||
ssize_t readKey();
|
||||
void processKeyboardEvent();
|
||||
int modifierKeyCorrection (int& key);
|
||||
void processDialogSwitchAccelerator();
|
||||
void processAccelerator (FWidget*);
|
||||
bool processDialogSwitchAccelerator();
|
||||
bool processAccelerator (FWidget*);
|
||||
void getX11ButtonState (int);
|
||||
bool parseX11Mouse();
|
||||
bool parseSGRMouse();
|
||||
|
|
|
@ -1026,10 +1026,7 @@ void FMenu::onKeyPress (FKeyEvent* ev)
|
|||
if ( statusBar() )
|
||||
statusBar()->clearMessage();
|
||||
|
||||
activatePrevWindow();
|
||||
raiseWindow (getActiveWindow());
|
||||
getActiveWindow()->getFocusWidget()->setFocus();
|
||||
getActiveWindow()->redraw();
|
||||
switchToPrevWindow();
|
||||
}
|
||||
|
||||
if ( statusBar() )
|
||||
|
|
|
@ -644,7 +644,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
|||
(*iter)->setSelected();
|
||||
(*iter)->setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
if ( focused_widget && ! focused_widget->isWindow() )
|
||||
focused_widget->redraw();
|
||||
|
||||
(*iter)->openMenu();
|
||||
|
@ -820,7 +820,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
|||
(*iter)->setSelected();
|
||||
(*iter)->setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
if ( focused_widget && ! focused_widget->isWindow() )
|
||||
focused_widget->redraw();
|
||||
|
||||
(*iter)->openMenu();
|
||||
|
|
|
@ -280,6 +280,13 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
|||
_METHOD_CALLBACK (this, &FMenuItem::cb_switchToDialog),
|
||||
dynamic_cast<FWidget::data_ptr>(win)
|
||||
);
|
||||
|
||||
win->addCallback
|
||||
(
|
||||
"destroy",
|
||||
_METHOD_CALLBACK (this, &FMenuItem::cb_destroyDialog),
|
||||
static_cast<FWidget::data_ptr>(win_item)
|
||||
);
|
||||
}
|
||||
|
||||
++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()
|
||||
{
|
||||
|
|
|
@ -65,6 +65,7 @@ class FMenuItem : public FWidget
|
|||
void processDeactivate();
|
||||
void createDialogList (FMenu*);
|
||||
void cb_switchToDialog (FWidget*, void*);
|
||||
void cb_destroyDialog (FWidget*, void*);
|
||||
virtual void processClicked();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -396,14 +396,13 @@ void FWindow::switchToPrevWindow()
|
|||
if ( ! active_window->isActiveWindow() )
|
||||
setActiveWindow(active_window);
|
||||
|
||||
raiseWindow (active_window);
|
||||
|
||||
if ( focus_widget )
|
||||
if ( focus_widget && ! focus_widget->isWindow() )
|
||||
{
|
||||
focus_widget->setFocus();
|
||||
|
||||
active_window->redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FWindow::activatePrevWindow()
|
||||
|
|
Loading…
Reference in New Issue