first steps for ctrl-v for input
Problems remaining: paste probably iss too long for ( problem for text input labels ) paste is countet as one single input which deletes the whole pasted string on pressing backspace.
This commit is contained in:
parent
ae6f522917
commit
8d315ba744
|
@ -99,10 +99,12 @@ bool ChatManager::textInput(std::string inputText) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] inputText [%s]\n",__FILE__,__FUNCTION__,__LINE__,inputText.c_str());
|
||||
|
||||
int maxTextLenAllowed = (customCB != NULL ? this->maxCustomTextLength : maxTextLenght);
|
||||
if(editEnabled && (int)textCharLength.size() < maxTextLenAllowed) {
|
||||
int maxpaste=0;
|
||||
maxpaste=maxTextLenAllowed-text.length();
|
||||
if(editEnabled && (int)text.length() < maxTextLenAllowed) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
textCharLength.push_back(inputText.length());
|
||||
this->text +=inputText;
|
||||
this->text +=inputText.substr (0,maxpaste);
|
||||
updateAutoCompleteBuffer();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -341,6 +341,27 @@ bool Window::handleEvent() {
|
|||
if(global_window) {
|
||||
keyDownConsumed=global_window->eventSdlKeyDown(event.key);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
switch (event.key.keysym.sym) {
|
||||
case SDLK_v:
|
||||
if (event.key.keysym.mod & KMOD_CTRL) {
|
||||
/* Ctrl-V, paste form clipbord */
|
||||
char *text = SDL_GetClipboardText();
|
||||
if (*text) {
|
||||
printf("Clipboard text: %s\n", text);
|
||||
if(global_window->eventTextInput(text) == true) {
|
||||
keyDownConsumed=true;
|
||||
}
|
||||
} else {
|
||||
printf("Clipboard text is empty\n");
|
||||
}
|
||||
SDL_free(text);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Stop unprintable characters (ctrl+, alt+ and escape),
|
||||
|
|
Loading…
Reference in New Issue