コード例 #1
0
ファイル: Control.cpp プロジェクト: SethGibson/Cinder-UI
bool Control::getIsBindedToModifier( ci::app::KeyEvent &event )
{
    if( event.isMetaDown() && mKeyModifier == app::KeyEvent::META_DOWN )
    {
        return true;
    }
    else if ( event.isAltDown() && mKeyModifier == app::KeyEvent::ALT_DOWN )
    {
        return true;
    }
    else if( event.isControlDown() && mKeyModifier == app::KeyEvent::CTRL_DOWN )
    {
        return true;
    }
    return false;
}
コード例 #2
0
ファイル: Control.cpp プロジェクト: SethGibson/Cinder-UI
bool Control::getIsModifierDown( ci::app::KeyEvent &event )
{
    if( event.isMetaDown() )
    {
        return true;
    }
    else if ( event.isAltDown() )
    {
        return true;
    }
    else if( event.isControlDown() )
    {
        return true;
    }
    else if( event.isShiftDown() )
    {
        return true;
    }
    else if( event.isAccelDown() )
    {
        return true;
    }
    return false;
}
コード例 #3
0
ファイル: TextInput.cpp プロジェクト: rezaali/Cinder-UI
void TextInput::keyDown( ci::app::KeyEvent &event )
{
	if( mClicked ) {
		if( event.getCode() == KeyEvent::KEY_v && event.isMetaDown() ) {
			if( Clipboard::hasString() ) {
				setValue( Clipboard::getString() );
				if( (int)mTrigger & (int)Trigger::CHANGE ) {
					trigger();
				}
			}
		}
		else {
			switch( event.getCode() ) {
			case KeyEvent::KEY_RIGHT: {
				if( mCursorPosition == mMaxDisplayLength && (int)mValue.substr( mStartIndex ).length() > mMaxDisplayLength ) {
					mStartIndex++;
					mDisplayValue = mValue.substr( mStartIndex, mMaxDisplayLength );
					mLabelRef->setLabel( mDisplayValue );
				}
				else if( mCursorPosition < (int)mDisplayValue.length() ) {
					mCursorPosition = mCursorPosition + 1;
				}
				setNeedsDisplay();
			} break;

			case KeyEvent::KEY_LEFT: {
				if( mCursorPosition == 0 && mStartIndex > 0 ) {
					mStartIndex--;
					mDisplayValue = mValue.substr( mStartIndex, mMaxDisplayLength );
					mLabelRef->setLabel( mDisplayValue );
				}
				else {
					mCursorPosition = mCursorPosition > 0 ? mCursorPosition - 1 : mCursorPosition;
				}
				setNeedsDisplay();
			} break;

			case KeyEvent::KEY_DELETE:
			case KeyEvent::KEY_BACKSPACE: {
				deleteCharacter();
			} break;

			case KeyEvent::KEY_UNKNOWN:
			case KeyEvent::KEY_TAB:
			case KeyEvent::KEY_CLEAR:
			case KeyEvent::KEY_KP0:
			case KeyEvent::KEY_KP1:
			case KeyEvent::KEY_KP2:
			case KeyEvent::KEY_KP3:
			case KeyEvent::KEY_KP4:
			case KeyEvent::KEY_KP5:
			case KeyEvent::KEY_KP6:
			case KeyEvent::KEY_KP7:
			case KeyEvent::KEY_KP8:
			case KeyEvent::KEY_KP9:
			case KeyEvent::KEY_KP_DIVIDE:
			case KeyEvent::KEY_KP_MULTIPLY:
			case KeyEvent::KEY_KP_PLUS:
			case KeyEvent::KEY_KP_EQUALS:
			case KeyEvent::KEY_UP:
			case KeyEvent::KEY_DOWN:
			case KeyEvent::KEY_INSERT:
			case KeyEvent::KEY_HOME:
			case KeyEvent::KEY_END:
			case KeyEvent::KEY_PAGEUP:
			case KeyEvent::KEY_PAGEDOWN:
			case KeyEvent::KEY_F1:
			case KeyEvent::KEY_F2:
			case KeyEvent::KEY_F3:
			case KeyEvent::KEY_F4:
			case KeyEvent::KEY_F5:
			case KeyEvent::KEY_F6:
			case KeyEvent::KEY_F7:
			case KeyEvent::KEY_F8:
			case KeyEvent::KEY_F9:
			case KeyEvent::KEY_F10:
			case KeyEvent::KEY_F11:
			case KeyEvent::KEY_F12:
			case KeyEvent::KEY_F13:
			case KeyEvent::KEY_F14:
			case KeyEvent::KEY_F15:
			case KeyEvent::KEY_NUMLOCK:
			case KeyEvent::KEY_CAPSLOCK:
			case KeyEvent::KEY_SCROLLOCK:
			case KeyEvent::KEY_RSHIFT:
			case KeyEvent::KEY_LSHIFT:
			case KeyEvent::KEY_RCTRL:
			case KeyEvent::KEY_LCTRL:
			case KeyEvent::KEY_RALT:
			case KeyEvent::KEY_LALT:
			case KeyEvent::KEY_RMETA:
			case KeyEvent::KEY_LMETA:
			case KeyEvent::KEY_LSUPER:
			case KeyEvent::KEY_RSUPER:
			case KeyEvent::KEY_MODE:
			case KeyEvent::KEY_COMPOSE:
			case KeyEvent::KEY_HELP:
			case KeyEvent::KEY_PRINT:
			case KeyEvent::KEY_SYSREQ:
			case KeyEvent::KEY_BREAK:
			case KeyEvent::KEY_MENU:
			case KeyEvent::KEY_POWER:
			case KeyEvent::KEY_EURO:
			case KeyEvent::KEY_UNDO:
				break;

			case KeyEvent::KEY_KP_ENTER:
			case KeyEvent::KEY_RETURN: {
				mClicked = false;
				if( (int)mTrigger & (int)Trigger::END ) {
					trigger();
					setNeedsDisplay();
				}
				if( mFormat.mAutoClear ) {
					setValue( "" );
				}
			} break;

			default: {
				if( mFormat.mNumeric ) {
					if( event.getChar() == '-' && mValue.length() == 0 ) {
						insertCharacter( string( 1, event.getChar() ) );
					}
					else if( event.getChar() == '.' && mValue.find( "." ) == string::npos ) {
						insertCharacter( string( 1, event.getChar() ) );
					}
					else if( isdigit( event.getChar() ) ) {
						insertCharacter( string( 1, event.getChar() ) );
					}
				}
				else {
					insertCharacter( string( 1, event.getChar() ) );
				}
			} break;
			}
		}
	}
}