record and replay control focus events
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <sstream>
|
||||||
#include "dialog.hpp"
|
#include "dialog.hpp"
|
||||||
#include "gfx/tiling.hpp" // for bg
|
#include "gfx/tiling.hpp" // for bg
|
||||||
#include "fileio/resmgr/res_dialog.hpp"
|
#include "fileio/resmgr/res_dialog.hpp"
|
||||||
@@ -541,6 +542,13 @@ void cDialog::handle_events() {
|
|||||||
auto info = info_from_action(next_action);
|
auto info = info_from_action(next_action);
|
||||||
eKeyMod mods = static_cast<eKeyMod>(atoi(info["mods"].c_str()));
|
eKeyMod mods = static_cast<eKeyMod>(atoi(info["mods"].c_str()));
|
||||||
controls[info["id"]]->triggerClickHandler(*this, info["id"], mods);
|
controls[info["id"]]->triggerClickHandler(*this, info["id"], mods);
|
||||||
|
}else if(next_action_type() == "control_focus"){
|
||||||
|
Element* next_action = pop_next_action();
|
||||||
|
auto info = info_from_action(next_action);
|
||||||
|
bool losing;
|
||||||
|
istringstream sstr(info["losing"]);
|
||||||
|
sstr >> losing;
|
||||||
|
controls[info["id"]]->triggerFocusHandler(*this, info["id"], losing);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
while(win.pollEvent(currentEvent)) handle_one_event(currentEvent);
|
while(win.pollEvent(currentEvent)) handle_one_event(currentEvent);
|
||||||
|
|||||||
@@ -359,6 +359,12 @@ bool cControl::triggerClickHandler(cDialog& dlg, std::string id, eKeyMod mods){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cControl::triggerFocusHandler(cDialog& dlg, std::string id, bool losing){
|
bool cControl::triggerFocusHandler(cDialog& dlg, std::string id, bool losing){
|
||||||
|
if(recording){
|
||||||
|
std::stringstream sstr;
|
||||||
|
sstr << losing;
|
||||||
|
std::map<std::string, std::string> action_info = {{"id", id}, {"losing", sstr.str()}};
|
||||||
|
record_action("control_focus", action_info);
|
||||||
|
}
|
||||||
if(losing) return triggerEvent<EVT_DEFOCUS>(dlg, id);
|
if(losing) return triggerEvent<EVT_DEFOCUS>(dlg, id);
|
||||||
triggerEvent<EVT_FOCUS>(dlg, id);
|
triggerEvent<EVT_FOCUS>(dlg, id);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user