Avoid sending events to deactivated controls.
Before the activation status of widgets wasn't checked for keyboard events (patch #1645).
This commit is contained in:
parent
c1685e40ce
commit
3f3e55c7a6
2 changed files with 20 additions and 5 deletions
|
@ -49,6 +49,7 @@ Version 1.9.0-svn:
|
|||
screen
|
||||
* Added the total number of villages to the status table lists
|
||||
* Added a new attack dialog, available for testing with --new-widgets
|
||||
* Patch #1645: Fixed a bug sending keyboard events to deactivated controls
|
||||
* WML Engine:
|
||||
* Deprecated [set_variable]'s random key, use rand instead
|
||||
* Renamed [unit][status] healable to unhealable so it can default to 'no'
|
||||
|
|
|
@ -787,12 +787,18 @@ void tdistributor::signal_handler_sdl_key_down(const SDLKey key
|
|||
DBG_GUI_E << LOG_HEADER << event::SDL_KEY_DOWN << ".\n";
|
||||
|
||||
if(keyboard_focus_) {
|
||||
// Attempt to cast to control, to avoid sending events if the
|
||||
// widget is disabled. If the cast fails, we assume the widget
|
||||
// is enabled and ready to receive events.
|
||||
tcontrol* control = dynamic_cast<tcontrol*>(keyboard_focus_);
|
||||
if(!control || control->get_active()) {
|
||||
DBG_GUI_E << LOG_HEADER << "Firing: " << event::SDL_KEY_DOWN << ".\n";
|
||||
if(owner_.fire(event::SDL_KEY_DOWN
|
||||
, *keyboard_focus_, key, modifier, unicode)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(std::vector<twidget*>::reverse_iterator
|
||||
ritor = keyboard_focus_chain_.rbegin()
|
||||
|
@ -817,6 +823,14 @@ void tdistributor::signal_handler_sdl_key_down(const SDLKey key
|
|||
continue;
|
||||
}
|
||||
|
||||
// Attempt to cast to control, to avoid sending events if the
|
||||
// widget is disabled. If the cast fails, we assume the widget
|
||||
// is enabled and ready to receive events.
|
||||
tcontrol* control = dynamic_cast<tcontrol*>(keyboard_focus_);
|
||||
if(control != NULL && !control->get_active()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DBG_GUI_E << LOG_HEADER << "Firing: " << event::SDL_KEY_DOWN << ".\n";
|
||||
if(owner_.fire(event::SDL_KEY_DOWN
|
||||
, **ritor, key, modifier, unicode)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue