record and replay text field input

This commit is contained in:
2024-08-24 12:59:45 -05:00
committed by Celtic Minstrel
parent f597bbc298
commit ad9ad3dc3c
4 changed files with 67 additions and 0 deletions

View File

@@ -543,6 +543,10 @@ void cDialog::handle_events() {
if(info["id"].empty()) continue;
eKeyMod mods = static_cast<eKeyMod>(std::stoi(info["mods"]));
controls[info["id"]]->triggerClickHandler(*this, info["id"], mods);
}else if(replaying && has_next_action() && next_action_type() == "field_input"){
Element& next_action = pop_next_action();
cKey key = key_from_action(next_action);
dynamic_cast<cTextField&>(getControl(currentFocus)).handleInput(key);
}else{
while(win.pollEvent(currentEvent)) handle_one_event(currentEvent, fps_limiter);
}

View File

@@ -17,6 +17,7 @@
#include "tools/keymods.hpp"
#include "tools/winutil.hpp"
#include "tools/cursors.hpp"
#include "replay.hpp"
bool cTextField::callHandler(event_fcn<EVT_DEFOCUS>::type onFocus, cDialog& me, std::string id) {
if(field_type != FLD_TEXT) {
@@ -396,6 +397,9 @@ static cKey divineFunction(cKey key) {
}
void cTextField::handleInput(cKey key) {
if(recording){
record_field_input(key);
}
changeMade = true;
bool select = mod_contains(key.mod, mod_shift);
bool haveSelection = insertionPoint != selectionPoint;