Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/SFGUI/Entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class SFGUI_API Entry : public Widget {

// Signals.
static Signal::SignalID OnTextChanged; //!< Fired when the text changes.
static Signal::SignalID OnEnterKeyPressed; //!< Fired when the enter key was pressed.

protected:
/** Ctor.
Expand Down
6 changes: 5 additions & 1 deletion src/SFGUI/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace sfg {

// Signals.
Signal::SignalID Entry::OnTextChanged = 0;
Signal::SignalID Entry::OnEnterKeyPressed = 0;

Entry::Entry() :
m_string(),
Expand Down Expand Up @@ -179,7 +180,10 @@ void Entry::HandleKeyEvent( sf::Keyboard::Key key, bool press ) {
}

switch( key ) {
case sf::Keyboard::BackSpace: { // backspace
case sf::Keyboard::Enter: {
GetSignals().Emit( OnEnterKeyPressed );
} break;
case sf::Keyboard::Backspace: {
if( ( m_string.getSize() > 0 ) && ( m_cursor_position > 0 ) ) {
m_string.erase( static_cast<std::size_t>( m_cursor_position - 1 ) );

Expand Down