Skip to content

Commit

Permalink
hiro: fix double character inputs in Windows HexEdit widget (#1798)
Browse files Browse the repository at this point in the history
At some point it might be worth going through the list of widgets to
understand which ones require WM_KEYDOWN messages to be forwarded by
Application_keyboardProc. For the time being, it's clear the HexEdit
widget is not among them, so this change disables forwarding for that
widget type.

As an added bonus, this change also makes the number pad functional.
  • Loading branch information
invertego authored Jan 28, 2025
1 parent 1a5559a commit bf9aae5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hiro/windows/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ static auto Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
//TODO: does this really need to be hooked here?
#if defined(Hiro_Widget)
if(auto widget = dynamic_cast<mWidget*>(object)) {
if(auto self = widget->self()) {
if(auto result = self->windowProc(self->hwnd, msg, wparam, lparam)) {
return result();
if(!dynamic_cast<mHexEdit*>(object)) {
if(auto self = widget->self()) {
if(auto result = self->windowProc(self->hwnd, msg, wparam, lparam)) {
return result();
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions hiro/windows/widget/hex-edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ auto pHexEdit::keyPress(u32 scancode) -> bool {
}

//convert scancode to hex nibble
scancode = pKeyboard::_translate(scancode, 0);
if(scancode >= '0' && scancode <= '9') scancode = scancode - '0';
else if(scancode >= 'A' && scancode <= 'F') scancode = scancode - 'A' + 10;
else if(scancode >= 'a' && scancode <= 'f') scancode = scancode - 'a' + 10;
Expand Down

0 comments on commit bf9aae5

Please sign in to comment.