Skip to content

Commit

Permalink
Fix onKeyDown events return value over some UI components.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Feb 4, 2025
1 parent 0b7dad2 commit 52fb2a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/eepp/ui/uicheckbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,20 @@ bool UICheckBox::applyProperty( const StyleSheetProperty& attribute ) {
return true;
}

Uint32 UICheckBox::onKeyDown( const KeyEvent& Event ) {
UITextView::onKeyDown( Event );
Uint32 UICheckBox::onKeyDown( const KeyEvent& event ) {
UITextView::onKeyDown( event );

if ( Event.getKeyCode() == KEY_SPACE ) {
if ( event.getKeyCode() == KEY_SPACE ) {
if ( Sys::getTicks() - mLastTick > 250 ) {
mLastTick = Sys::getTicks();

setChecked( !mChecked );

return 1;
}
}

return 1;
return UITextView::onKeyDown( event );
}

void UICheckBox::onAlphaChange() {
Expand Down
4 changes: 2 additions & 2 deletions src/eepp/ui/uilistbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ void UIListBox::selectNext() {
}

Uint32 UIListBox::onKeyDown( const KeyEvent& event ) {
UINode::onKeyDown( event );
Uint32 ret = UINode::onKeyDown( event );

if ( mFlags & UI_MULTI_SELECT )
return 0;
Expand Down Expand Up @@ -961,7 +961,7 @@ Uint32 UIListBox::onKeyDown( const KeyEvent& event ) {

itemKeyEvent( event );

return 1;
return ret;
}

Uint32 UIListBox::onMessage( const NodeMessage* Msg ) {
Expand Down
2 changes: 1 addition & 1 deletion src/eepp/ui/uitextview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ Uint32 UIAnchor::onKeyDown( const KeyEvent& event ) {
}
}

return 0;
return UIWidget::onKeyDown( event );
}

std::string UIAnchor::getPropertyString( const PropertyDefinition* propertyDef,
Expand Down
2 changes: 1 addition & 1 deletion src/eepp/ui/uiwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ Uint32 UIWindow::onKeyDown( const KeyEvent& event ) {
std::string cmd = mKeyBindings.getCommandFromKeyBind( { event.getKeyCode(), event.getMod() } );
if ( !cmd.empty() ) {
executeKeyBindingCommand( cmd );
return 0;
return 1;
}
return UIWidget::onKeyDown( event );
}
Expand Down

0 comments on commit 52fb2a3

Please sign in to comment.