MCPcopy Create free account
hub / github.com/cinder/Cinder / processNumerical

Method processNumerical

samples/iosKeyboard/src/iosKeyboardApp.cpp:103–118  ·  view source on GitHub ↗

manually build a string of numerical digits, filtering out everything else

Source from the content-addressed store, hash-verified

101
102// manually build a string of numerical digits, filtering out everything else
103void iosKeyboardApp::processNumerical( const KeyEvent &event )
104{
105 if( event.getCode() == KeyEvent::KEY_BACKSPACE && ! mNumericalTextView.mText.empty() )
106 mNumericalTextView.mText.pop_back();
107 else if( isdigit( event.getChar() ) ) {
108 mNumericalTextView.mText.push_back( event.getChar() );
109 Rectf fitRect = mNumericalTextView.getTextBounds();
110 TextBox tbox = TextBox().font( mFont ).text( mNumericalTextView.mText ).size( TextBox::GROW, TextBox::GROW );
111 vec2 size = tbox.measure();
112
113 if( size.x > fitRect.getWidth() ) {
114 console() << "OVERFLOW" << endl;
115 mNumericalTextView.mText.pop_back();
116 }
117 }
118}
119
120// Don't return on enter here, which allows the KEY_RETURN to be interpreted as a newline.
121// Instead, grab the internal keyboard string, which can also handle complex character sequences, such as kanji or emoji

Callers

nothing calls this directly

Calls 8

TextBoxFunction · 0.85
pop_backMethod · 0.80
getTextBoundsMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
measureMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected