Status and menu bar insert accelerator keys into root widget
This commit is contained in:
parent
fbb3c8ef11
commit
2acda53224
|
@ -1,3 +1,7 @@
|
||||||
|
2016-07-12 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* The status bar and the menu bar insert now the accelerator keys
|
||||||
|
into the global scope of the root widget
|
||||||
|
|
||||||
2016-07-10 Markus Gans <guru.mail@muenster.de>
|
2016-07-10 Markus Gans <guru.mail@muenster.de>
|
||||||
* Remove obsolete code from FDialog destructor
|
* Remove obsolete code from FDialog destructor
|
||||||
* FDialog focus fix
|
* FDialog focus fix
|
||||||
|
|
59
src/fapp.cpp
59
src/fapp.cpp
|
@ -391,35 +391,14 @@ void FApplication::processKeyboardEvent()
|
||||||
&& ! k_press_ev.isAccepted()
|
&& ! k_press_ev.isAccepted()
|
||||||
&& ! k_down_ev.isAccepted() )
|
&& ! k_down_ev.isAccepted() )
|
||||||
{
|
{
|
||||||
// keyboard accelerator
|
// windows keyboard accelerator
|
||||||
FWidget* window = static_cast<FWidget*>(active_window);
|
FWidget* window = static_cast<FWidget*>(active_window);
|
||||||
|
|
||||||
if ( ! window )
|
if ( window )
|
||||||
window = getRootWidget();
|
processAccelerator (window);
|
||||||
|
|
||||||
if ( window
|
// global keyboard accelerator
|
||||||
&& window->accelerator_list
|
processAccelerator (getRootWidget());
|
||||||
&& ! window->accelerator_list->empty() )
|
|
||||||
{
|
|
||||||
FWidget::Accelerators::const_iterator iter, end;
|
|
||||||
iter = window->accelerator_list->begin();
|
|
||||||
end = window->accelerator_list->end();
|
|
||||||
|
|
||||||
while ( iter != end )
|
|
||||||
{
|
|
||||||
if ( quit_now || app_exit_loop )
|
|
||||||
break;
|
|
||||||
|
|
||||||
if ( iter->key == key )
|
|
||||||
{
|
|
||||||
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
|
|
||||||
sendEvent (iter->object, &a_ev);
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
++iter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // end of else
|
} // end of else
|
||||||
}
|
}
|
||||||
|
@ -449,6 +428,34 @@ void FApplication::processKeyboardEvent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FApplication::processAccelerator (FWidget* widget)
|
||||||
|
{
|
||||||
|
if ( widget
|
||||||
|
&& widget->accelerator_list
|
||||||
|
&& ! widget->accelerator_list->empty() )
|
||||||
|
{
|
||||||
|
FWidget::Accelerators::const_iterator iter, end;
|
||||||
|
iter = widget->accelerator_list->begin();
|
||||||
|
end = widget->accelerator_list->end();
|
||||||
|
|
||||||
|
while ( iter != end )
|
||||||
|
{
|
||||||
|
if ( quit_now || app_exit_loop )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ( iter->key == key )
|
||||||
|
{
|
||||||
|
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
|
||||||
|
sendEvent (iter->object, &a_ev);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::getX11ButtonState (int button)
|
void FApplication::getX11ButtonState (int button)
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,6 +124,7 @@ class FApplication : public FWidget
|
||||||
bool KeyPressed();
|
bool KeyPressed();
|
||||||
ssize_t readKey();
|
ssize_t readKey();
|
||||||
void processKeyboardEvent();
|
void processKeyboardEvent();
|
||||||
|
void processAccelerator (FWidget*);
|
||||||
void getX11ButtonState (int);
|
void getX11ButtonState (int);
|
||||||
bool parseX11Mouse();
|
bool parseX11Mouse();
|
||||||
bool parseSGRMouse();
|
bool parseSGRMouse();
|
||||||
|
|
|
@ -1160,41 +1160,35 @@ void FWidget::emitCallback (FString emit_signal)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::addAccelerator (int key, FWidget* obj)
|
void FWidget::addAccelerator (int key, FWidget* obj)
|
||||||
{
|
{
|
||||||
FWidget* window = FWindow::getWindowWidget(obj);
|
FWidget* widget = FWindow::getWindowWidget(obj);
|
||||||
accelerator accel = { key, obj };
|
accelerator accel = { key, obj };
|
||||||
|
|
||||||
if ( ! window )
|
if ( ! widget || widget == statusbar || widget == menubar )
|
||||||
window = getRootWidget();
|
widget = getRootWidget();
|
||||||
|
|
||||||
if ( window == statusbar || window == menubar )
|
if ( widget && widget->accelerator_list )
|
||||||
window = FWindow::getWindowWidget(getParentWidget());
|
widget->accelerator_list->push_back(accel);
|
||||||
|
|
||||||
if ( window && window->accelerator_list )
|
|
||||||
window->accelerator_list->push_back(accel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::delAccelerator (FWidget* obj)
|
void FWidget::delAccelerator (FWidget* obj)
|
||||||
{
|
{
|
||||||
FWidget* window = FWindow::getWindowWidget(this);
|
FWidget* widget = FWindow::getWindowWidget(this);
|
||||||
|
|
||||||
if ( ! window )
|
if ( ! widget || widget == statusbar || widget == menubar )
|
||||||
window = getRootWidget();
|
widget = getRootWidget();
|
||||||
|
|
||||||
if ( window == statusbar || window == menubar )
|
if ( widget
|
||||||
window = FWindow::getWindowWidget(getParentWidget());
|
&& widget->accelerator_list
|
||||||
|
&& ! widget->accelerator_list->empty() )
|
||||||
if ( window
|
|
||||||
&& window->accelerator_list
|
|
||||||
&& ! window->accelerator_list->empty() )
|
|
||||||
{
|
{
|
||||||
FWidget::Accelerators::iterator iter;
|
FWidget::Accelerators::iterator iter;
|
||||||
iter = window->accelerator_list->begin();
|
iter = widget->accelerator_list->begin();
|
||||||
|
|
||||||
while ( iter != window->accelerator_list->end() )
|
while ( iter != widget->accelerator_list->end() )
|
||||||
{
|
{
|
||||||
if ( iter->object == obj )
|
if ( iter->object == obj )
|
||||||
iter = window->accelerator_list->erase(iter);
|
iter = widget->accelerator_list->erase(iter);
|
||||||
else
|
else
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue