ofxImGui
ofxImGui copied to clipboard
ctrl-c / ctrl-v clipboard callbacks never called on OSX
Hi, on OSX I can't have TextInput copy/paste working. Dunno if it's me but BaseEngine::getClipboardString()
and BaseEngine::setClipboardString()
are never called...
I tried with ctrl-c ctrl-v keys, also with cmd-c cmd-v keys (with io.ShortcutsUseSuperKey = true)
Using cmd-c or cmd-v erases the input's content and add a 'c' or a 'v'
A few steps towards a solution. The is_super_down mod to imgui above and this does seem to work. It seems just returning &ofGetWindowPtr()->getClipboardString()[0] returns a variable that goes out of scope. Creating a static instance helps with that, but I'm not sure if it is being released somewhere else after. Another pair of eyes wouldn't hurt. In general it seems because keyboard inputs are platform specific this is a bit unsupported in imgui.
//--------------------------------------------------------------
const char* BaseEngine::getClipboardString()
{
static string str = ofGetWindowPtr()->getClipboardString();
if(str.size()){
str = &ofGetWindowPtr()->getClipboardString()[0];
return str.c_str();
}
return "";
}
//--------------------------------------------------------------
void BaseEngine::setClipboardString(const char * text)
{
static string str = ofToString(text);
ofGetWindowPtr()->setClipboardString(str.c_str());
}
Ctrl-C & Ctrl-V work OK on Win32 , but direct calls to getClipBoardString don't.
See https://github.com/jvcleave/ofxImGui/issues/56