1
0
mirror of synced 2024-11-12 10:10:53 +01:00

fix: Editing bytes in the hex editor being broken

Fixed #521
This commit is contained in:
WerWolv 2022-06-03 10:53:03 +02:00
parent bf1441223c
commit d1d73bcff6
2 changed files with 7 additions and 3 deletions

View File

@ -538,7 +538,7 @@ namespace hex {
namespace ContentRegistry::HexEditor {
const int DataVisualizer::TextInputFlags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_NoHorizontalScroll | ImGuiInputTextFlags_EnterReturnsTrue;
const int DataVisualizer::TextInputFlags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoHorizontalScroll;
bool DataVisualizer::drawDefaultEditingTextBox(u64 address, const char *format, ImGuiDataType dataType, u8 *data, ImGuiInputTextFlags flags) const {
struct UserData {

View File

@ -484,8 +484,9 @@ namespace hex::plugin::builtin {
ImGui::SetKeyboardFocusHere();
ImGui::CaptureKeyboardFromApp(true);
if (this->m_currDataVisualizer->drawEditing(address, this->m_editingBytes.data(), this->m_editingBytes.size(), this->m_upperCaseHex, this->m_enteredEditingMode) || this->m_shouldModifyValue) {
provider->write(address, this->m_editingBytes.data(), this->m_editingBytes.size());
if (this->m_currDataVisualizer->drawEditing(*this->m_editingAddress, this->m_editingBytes.data(), this->m_editingBytes.size(), this->m_upperCaseHex, this->m_enteredEditingMode) || this->m_shouldModifyValue) {
provider->write(*this->m_editingAddress, this->m_editingBytes.data(), this->m_editingBytes.size());
if (!this->m_selectionChanged && !ImGui::IsMouseDown(ImGuiMouseButton_Left) && !ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
auto nextEditingAddress = *this->m_editingAddress + this->m_currDataVisualizer->getBytesPerCell();
@ -499,6 +500,9 @@ namespace hex::plugin::builtin {
this->m_editingAddress = std::nullopt;
}
this->m_editingBytes.resize(size);
std::memcpy(this->m_editingBytes.data(), data, size);
this->m_shouldModifyValue = false;
}