Bind accelerator key from the FMenuItem to the root widget
This commit is contained in:
parent
2acda53224
commit
9ef3bd3243
|
@ -1,3 +1,6 @@
|
||||||
|
2016-07-13 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Bind accelerator key from the FMenuItem to the root widget
|
||||||
|
|
||||||
2016-07-12 Markus Gans <guru.mail@muenster.de>
|
2016-07-12 Markus Gans <guru.mail@muenster.de>
|
||||||
* The status bar and the menu bar insert now the accelerator keys
|
* The status bar and the menu bar insert now the accelerator keys
|
||||||
into the global scope of the root widget
|
into the global scope of the root widget
|
||||||
|
|
|
@ -177,8 +177,11 @@ Class digramm
|
||||||
: : │ ┌───┤ FMenuBar │ :
|
: : │ ┌───┤ FMenuBar │ :
|
||||||
: : ┌───────────┐ └─────┤ └──────────┘ :
|
: : ┌───────────┐ └─────┤ └──────────┘ :
|
||||||
: : │ FMenuList │◄──────────┤ ┌───────┐ :
|
: : │ FMenuList │◄──────────┤ ┌───────┐ :
|
||||||
: : └────┬──────┘ └───┤ FMenu │ :
|
: : └────┬──────┘ └───┤ FMenu │◄──┐ :
|
||||||
: : : └───────┘ :
|
: : : └───────┘ │ :
|
||||||
|
: : : ┌─────────────────┐ │ :
|
||||||
|
: : : │ FDialogListMenu ├───┘ :
|
||||||
|
: : : └─────────────────┘ :
|
||||||
: : 1: ┌────────────────┐* :
|
: : 1: ┌────────────────┐* :
|
||||||
: : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
|
: : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
|
||||||
: : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
|
: : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
|
||||||
|
|
|
@ -78,8 +78,11 @@
|
||||||
: : │ ┌───┤ FMenuBar │ :
|
: : │ ┌───┤ FMenuBar │ :
|
||||||
: : ┌───────────┐ └─────┤ └──────────┘ :
|
: : ┌───────────┐ └─────┤ └──────────┘ :
|
||||||
: : │ FMenuList │◄──────────┤ ┌───────┐ :
|
: : │ FMenuList │◄──────────┤ ┌───────┐ :
|
||||||
: : └────┬──────┘ └───┤ FMenu │ :
|
: : └────┬──────┘ └───┤ FMenu │◄──┐ :
|
||||||
: : : └───────┘ :
|
: : : └───────┘ │ :
|
||||||
|
: : : ┌─────────────────┐ │ :
|
||||||
|
: : : │ FDialogListMenu ├───┘ :
|
||||||
|
: : : └─────────────────┘ :
|
||||||
: : 1: ┌────────────────┐* :
|
: : 1: ┌────────────────┐* :
|
||||||
: : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
|
: : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
|
||||||
: : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
|
: : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
|
||||||
|
|
|
@ -319,19 +319,25 @@ void FMenuItem::processClicked()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenuItem::isWindowsMenu (FWidget* w) const
|
bool FMenuItem::isWindowsMenu (FWidget* w) const
|
||||||
{
|
{
|
||||||
return w->isDialog();
|
return ( ! w ) ? false : w->isDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenuItem::isMenuBar (FWidget* w) const
|
bool FMenuItem::isMenuBar (FWidget* w) const
|
||||||
{
|
{
|
||||||
return bool( strcmp ( w->getClassName()
|
if ( ! w )
|
||||||
, const_cast<char*>("FMenuBar") ) == 0 );
|
return false;
|
||||||
|
else
|
||||||
|
return bool( strcmp ( w->getClassName()
|
||||||
|
, const_cast<char*>("FMenuBar") ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenuItem::isMenu (FWidget* w) const
|
bool FMenuItem::isMenu (FWidget* w) const
|
||||||
{
|
{
|
||||||
|
if ( ! w )
|
||||||
|
return false;
|
||||||
|
|
||||||
bool m1 = ( strcmp ( w->getClassName()
|
bool m1 = ( strcmp ( w->getClassName()
|
||||||
, const_cast<char*>("FMenu") ) == 0 );
|
, const_cast<char*>("FMenu") ) == 0 );
|
||||||
bool m2 = ( strcmp ( w->getClassName()
|
bool m2 = ( strcmp ( w->getClassName()
|
||||||
|
@ -344,30 +350,13 @@ bool FMenuItem::isMenu (FWidget* w) const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenuItem::addAccelerator (int key, FWidget* obj)
|
void FMenuItem::addAccelerator (int key, FWidget* obj)
|
||||||
{
|
{
|
||||||
FWidget* super = super_menu;
|
FWidget* root = getRootWidget();
|
||||||
|
accelerator accel = { key, obj };
|
||||||
|
|
||||||
if ( ! super )
|
if ( root && root->accelerator_list )
|
||||||
return;
|
|
||||||
|
|
||||||
while ( super && strncmp ( super->getClassName()
|
|
||||||
, const_cast<char*>("FMenu"), 5) == 0 )
|
|
||||||
{
|
{
|
||||||
super = super->getParentWidget();
|
accel_key = key;
|
||||||
}
|
root->accelerator_list->push_back(accel);
|
||||||
|
|
||||||
if ( super )
|
|
||||||
{
|
|
||||||
FWidget* window = FWindow::getWindowWidget(super);
|
|
||||||
accelerator accel = { key, obj };
|
|
||||||
|
|
||||||
if ( ! window )
|
|
||||||
window = getRootWidget();
|
|
||||||
|
|
||||||
if ( window && window->accelerator_list )
|
|
||||||
{
|
|
||||||
accel_key = key;
|
|
||||||
window->accelerator_list->push_back(accel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isMenu(super_menu) )
|
if ( isMenu(super_menu) )
|
||||||
|
@ -382,41 +371,24 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenuItem::delAccelerator (FWidget* obj)
|
void FMenuItem::delAccelerator (FWidget* obj)
|
||||||
{
|
{
|
||||||
FWidget* super = super_menu;
|
FWidget* root = getRootWidget();
|
||||||
|
|
||||||
if ( ! super )
|
if ( root
|
||||||
return;
|
&& root->accelerator_list
|
||||||
|
&& ! root->accelerator_list->empty() )
|
||||||
while ( super && strncmp ( super->getClassName()
|
|
||||||
, const_cast<char*>("FMenu"), 5) == 0 )
|
|
||||||
{
|
{
|
||||||
super = super->getParentWidget();
|
FWidget::Accelerators::iterator iter;
|
||||||
}
|
iter = root->accelerator_list->begin();
|
||||||
|
|
||||||
if ( super )
|
while ( iter != root->accelerator_list->end() )
|
||||||
{
|
|
||||||
FWidget* window = FWindow::getWindowWidget(super);
|
|
||||||
|
|
||||||
if ( ! window )
|
|
||||||
window = getRootWidget();
|
|
||||||
|
|
||||||
if ( window
|
|
||||||
&& window->accelerator_list
|
|
||||||
&& ! window->accelerator_list->empty() )
|
|
||||||
{
|
{
|
||||||
FWidget::Accelerators::iterator iter;
|
if ( iter->object == obj )
|
||||||
iter = window->accelerator_list->begin();
|
|
||||||
|
|
||||||
while ( iter != window->accelerator_list->end() )
|
|
||||||
{
|
{
|
||||||
if ( iter->object == obj )
|
accel_key = 0;
|
||||||
{
|
iter = root->accelerator_list->erase(iter);
|
||||||
accel_key = 0;
|
|
||||||
iter = window->accelerator_list->erase(iter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++iter;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue