Skip to content

Commit

Permalink
Call uilist_callback::select when actually changing the selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrox committed Apr 30, 2020
1 parent c8a385b commit 42dcdf5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ void uilist::filterlist()
if( static_cast<int>( fentries.size() ) <= vmax ) {
vshift = 0;
}
if( callback != nullptr ) {
callback->select( this );
}
}

void uilist::inputfilter()
Expand Down Expand Up @@ -515,6 +518,9 @@ void uilist::setup()
}
}
}
if( callback != nullptr ) {
callback->select( this );
}
started = true;
}

Expand Down Expand Up @@ -657,9 +663,6 @@ void uilist::show()
mvwputch( window, point( pad_left + 1 + menu_entry_extra_text.left, estart + si ),
menu_entry_extra_text.color, menu_entry_extra_text.sym );
}
if( callback != nullptr && ei == selected ) {
callback->select( ei, this );
}
} else {
mvwprintz( window, point( pad_left + 1, estart + si ), c_light_gray, padspaces );
}
Expand Down Expand Up @@ -788,6 +791,9 @@ bool uilist::scrollby( const int scrollby )
}
if( static_cast<size_t>( fselected ) < fentries.size() ) {
selected = fentries [ fselected ];
if( callback != nullptr ) {
callback->select( this );
}
}
return true;
}
Expand Down Expand Up @@ -859,6 +865,9 @@ void uilist::query( bool loop, int timeout )
} else if( allow_disabled ) {
ret = entries[selected].retval; // disabled
}
if( callback != nullptr ) {
callback->select( this );
}
} else if( !fentries.empty() && ret_act == "CONFIRM" ) {
if( entries[ selected ].enabled ) {
ret = entries[ selected ].retval; // valid
Expand Down
2 changes: 1 addition & 1 deletion src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class uilist;
class uilist_callback
{
public:
virtual void select( int /*entnum*/, uilist * ) {}
virtual void select( uilist * ) {}
virtual bool key( const input_context &, const input_event &/*key*/, int /*entnum*/,
uilist * ) {
return false;
Expand Down

0 comments on commit 42dcdf5

Please sign in to comment.