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,12 +319,15 @@ 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
|
||||||
{
|
{
|
||||||
|
if ( ! w )
|
||||||
|
return false;
|
||||||
|
else
|
||||||
return bool( strcmp ( w->getClassName()
|
return bool( strcmp ( w->getClassName()
|
||||||
, const_cast<char*>("FMenuBar") ) == 0 );
|
, const_cast<char*>("FMenuBar") ) == 0 );
|
||||||
}
|
}
|
||||||
|
@ -332,6 +335,9 @@ bool FMenuItem::isMenuBar (FWidget* w) const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
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();
|
||||||
|
|
||||||
if ( ! super )
|
|
||||||
return;
|
|
||||||
|
|
||||||
while ( super && strncmp ( super->getClassName()
|
|
||||||
, const_cast<char*>("FMenu"), 5) == 0 )
|
|
||||||
{
|
|
||||||
super = super->getParentWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( super )
|
|
||||||
{
|
|
||||||
FWidget* window = FWindow::getWindowWidget(super);
|
|
||||||
accelerator accel = { key, obj };
|
accelerator accel = { key, obj };
|
||||||
|
|
||||||
if ( ! window )
|
if ( root && root->accelerator_list )
|
||||||
window = getRootWidget();
|
|
||||||
|
|
||||||
if ( window && window->accelerator_list )
|
|
||||||
{
|
{
|
||||||
accel_key = key;
|
accel_key = key;
|
||||||
window->accelerator_list->push_back(accel);
|
root->accelerator_list->push_back(accel);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isMenu(super_menu) )
|
if ( isMenu(super_menu) )
|
||||||
|
@ -382,43 +371,26 @@ 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( super )
|
|
||||||
{
|
|
||||||
FWidget* window = FWindow::getWindowWidget(super);
|
|
||||||
|
|
||||||
if ( ! window )
|
|
||||||
window = getRootWidget();
|
|
||||||
|
|
||||||
if ( window
|
|
||||||
&& window->accelerator_list
|
|
||||||
&& ! window->accelerator_list->empty() )
|
|
||||||
{
|
{
|
||||||
FWidget::Accelerators::iterator iter;
|
FWidget::Accelerators::iterator iter;
|
||||||
iter = window->accelerator_list->begin();
|
iter = root->accelerator_list->begin();
|
||||||
|
|
||||||
while ( iter != window->accelerator_list->end() )
|
while ( iter != root->accelerator_list->end() )
|
||||||
{
|
{
|
||||||
if ( iter->object == obj )
|
if ( iter->object == obj )
|
||||||
{
|
{
|
||||||
accel_key = 0;
|
accel_key = 0;
|
||||||
iter = window->accelerator_list->erase(iter);
|
iter = root->accelerator_list->erase(iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( isMenu(super_menu) )
|
if ( isMenu(super_menu) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue