void ScreenTextEntry::Input( const InputEventPlus &input ) { if( IsTransitioning() ) return; if( input.DeviceI == DeviceInput(DEVICE_KEYBOARD, KEY_BACK) ) { switch( input.type ) { case IET_FIRST_PRESS: case IET_REPEAT: BackspaceInAnswer(); default: break; } } else if( input.type == IET_FIRST_PRESS ) { wchar_t c = INPUTMAN->DeviceInputToChar(input.DeviceI,true); if( c >= L' ' ) { // todo: handle caps lock -aj TryAppendToAnswer( WStringToRString(wstring()+c) ); TextEnteredDirectly(); } } ScreenWithMenuElements::Input( input ); }
bool ScreenTextEntry::Input( const InputEventPlus &input ) { static bool bLCtrl = false, bRCtrl = false; if( IsTransitioning() ) return false; // bLCtrl and bRCtl are whether their respective Ctrl keys are held // We update them here. if( input.DeviceI == DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL) ) { switch( input.type ) { case IET_FIRST_PRESS: bLCtrl = true; break; case IET_RELEASE: bLCtrl = false; break; default: break; } } if( input.DeviceI == DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL) ) { switch( input.type ) { case IET_FIRST_PRESS: bRCtrl = true; break; case IET_RELEASE: bRCtrl = false; break; default: break; } } bool bHandled = false; if( input.DeviceI == DeviceInput(DEVICE_KEYBOARD, KEY_BACK) ) { switch( input.type ) { case IET_FIRST_PRESS: case IET_REPEAT: BackspaceInAnswer(); bHandled = true; default: break; } } else if( input.type == IET_FIRST_PRESS ) { wchar_t c = INPUTMAN->DeviceInputToChar(input.DeviceI,true); // Detect Ctrl+V if( ( c == L'v' || c == L'V' ) && ( bLCtrl || bRCtrl ) ) { TryAppendToAnswer( HOOKS->GetClipboard() ); TextEnteredDirectly(); // XXX: This doesn't seem appropriate but there's no TextPasted() bHandled = true; } else if( c >= L' ' ) { // todo: handle caps lock -aj TryAppendToAnswer( WStringToRString(wstring()+c) ); TextEnteredDirectly(); bHandled = true; } } return ScreenWithMenuElements::Input( input ) || bHandled; }