Fixed on GIT GLFW: SetClipboard not managing special characters

Pierrou

Active member
Joined
Jul 6, 2017
Messages
204
I forgot about that but I'm about to need to use clipboard for my next project since it's a sequel to an app I made in Blitzmax which leaned on it (in Blitzmax the clipboard handed special characters well)
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,042
I guess we need our own solution for the clipboard and not rely on GLFWs implementation.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,042
I forgot about that but I'm about to need to use clipboard for my next project since it's a sequel to an app I made in Blitzmax which leaned on it (in Blitzmax the clipboard handed special characters well)
Does it do that on all desktop platforms?
 

Pierrou

Active member
Joined
Jul 6, 2017
Messages
204
Good question, haven't tried on macOS, I will ASAP. I don't know if the BlitzMax code can be adapted or not+ I can't remember if it was vanilla BMax or something that came with WX Gadgets.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
715
For me it empties the clipboard on macOS platform.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
715
Using latest Cerberus-X, I tried it on Catalina 10.15.6 and up.
They all give empty clipboard.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
602
It looks like there is something going wrong with the conversion from String to cstring. If I put in some const char * text, setclipboard() works as expected on my MacBook. If I inspect the first char of "ü" I get different values. -61 from the const char* and -4 from the converted cx string.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
602
No, at least not yet. Sorry. I will have a look again this evening. Maybe someone can help me with some questions I have about this:
What is the difference between CX String in terms of the value each character has?
Where do special chars differ?
The other thing is that this is wrapped in ugly c++ template classes I don't know much about.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
715
I've done some testing (reading and setting the clipboard inside the os and cx, all the variants).

Everything works except :

Code:
If GetClipboard() ="ü" Then canvas.DrawText "This will not be printed",0,0 ' this will not react strangly enough
Print GetClipboard() ' < This *will* print ü

and:

Code:
SetClipboard "ü"

This will leave the os with an empty clipboard.
(and the console will be printed filled with empty strings that scrolls up)

Code:
SetClipboard "ü"
If GetClipboard() ="ü" Then imageCanvas.DrawText This won't happen either",0,0

Sadly I'm not very knowledgable about the details needed yet to solve it. But this might help.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
602
Ok. I managed to get it working on my MacBook and maybe on Windows, but I am not sure yet. And for Windows I need to find the function for getting the length of a C-String.
I modified some lines in glfwgame.cpp inside the targets native folder:

Code:
// At the beginning of the file I changed this line:
//static String::CString<char> GLFW_C_STR( const String &t ){ return t.ToCString<char>(); };
static String::CString<char> GLFW_C_STR( const String &t ){ return t.ToUtf8(); };


// And at line 637 I changed this.
        //return String(_text);
        return String::Load((unsigned char *)_text, t_strlen( _text ));

Edit: The function for the length of a c-string array is t_strlen() :) Here it seems to work on Mac(Big Sur), Win10 and Linux (Manjaro) .
 
Last edited:
Top Bottom