Minor nit in UIDropDownList.

This commit is contained in:
Martín Lucas Golini
2024-10-22 01:37:40 -03:00
parent badced81d5
commit 78f7cc7d60
2 changed files with 17 additions and 10 deletions

View File

@@ -38,17 +38,17 @@ UIDropDownList::UIDropDownList( const std::string& tag ) :
mListBox->setParent( this );
mListBox->addEventListener( Event::OnWidgetFocusLoss,
[this] ( auto event ) { onListBoxFocusLoss( event ); } );
[this]( auto event ) { onListBoxFocusLoss( event ); } );
mListBox->addEventListener( Event::OnItemSelected,
[this] ( auto event ) { onItemSelected( event ); } );
[this]( auto event ) { onItemSelected( event ); } );
mListBox->addEventListener( Event::OnItemClicked,
[this] ( auto event ) { onItemClicked( event ); } );
[this]( auto event ) { onItemClicked( event ); } );
mListBox->addEventListener( Event::OnItemKeyDown,
[this] ( auto event ) { onItemKeyDown( event ); } );
mListBox->addEventListener( Event::KeyDown, [this] ( auto event ) { onItemKeyDown( event ); } );
mListBox->addEventListener( Event::OnClear, [this] ( auto event ) { onWidgetClear( event ); } );
[this]( auto event ) { onItemKeyDown( event ); } );
mListBox->addEventListener( Event::KeyDown, [this]( auto event ) { onItemKeyDown( event ); } );
mListBox->addEventListener( Event::OnClear, [this]( auto event ) { onWidgetClear( event ); } );
mListBoxCloseCb = mListBox->addEventListener( Event::OnClose,
[this]( const Event* ) { mListBox = nullptr; } );
[this]( const Event* ) { mListBox = nullptr; } );
mListBox->addEventListener( Event::OnSelectionChanged, [this]( auto ) {
if ( !mListBox->hasSelection() )
mListBox->setSelected( 0 );
@@ -250,6 +250,10 @@ void UIDropDownList::onItemKeyDown( const Event* Event ) {
if ( KEvent->getKeyCode() == KEY_RETURN )
onItemClicked( Event );
else if ( KEvent->getKeyCode() == KEY_ESCAPE ) {
hide();
setFocus();
}
}
void UIDropDownList::onListBoxFocusLoss( const Event* ) {
@@ -278,6 +282,9 @@ void UIDropDownList::onItemSelected( const Event* ) {
sendCommonEvent( Event::OnItemSelected );
sendCommonEvent( Event::OnValueChange );
sendCommonEvent( Event::OnSelectionChanged );
if ( !mListBox->isEnabled() )
setFocus();
}
void UIDropDownList::show() {

View File

@@ -66,12 +66,12 @@ Uint32 UIListBoxItem::onMouseClick( const Vector2i& Pos, const Uint32& Flags ) {
if ( Flags & EE_BUTTONS_LRM ) {
UIListBox* LBParent = getParent()->getParent()->asType<UIListBox>();
if ( !LBParent->isMultiSelect() )
setFocus();
LBParent->itemClicked( this );
select();
if ( !LBParent->isMultiSelect() )
setFocus();
}
return UITextView::onMouseClick( Pos, Flags );