ofxImGui icon indicating copy to clipboard operation
ofxImGui copied to clipboard

ctrl-c / ctrl-v clipboard callbacks never called on OSX

Open cgimenez opened this issue 8 years ago • 2 comments

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'

cgimenez avatar Aug 01 '16 10:08 cgimenez

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());
	}
    

borg avatar Jan 12 '17 18:01 borg

Ctrl-C & Ctrl-V work OK on Win32 , but direct calls to getClipBoardString don't.

See https://github.com/jvcleave/ofxImGui/issues/56

rjx-ray avatar Jun 30 '17 07:06 rjx-ray