Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add OnEnterKeyPressed signal to Entry widget#80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vfjpl wants to merge1 commit intoTankOs:master
base:master
Choose a base branch
Loading
fromvfjpl:master
Open
Show file tree
Hide file tree
Changes fromall 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 deletionsinclude/SFGUI/Entry.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsrc/SFGUI/Entry.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp