Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » Mac OS » Clipboard Usage (I am experiencing difficulties in using the clipboard on macOS.)
Clipboard Usage [message #60409] Thu, 04 January 2024 17:40 Go to next message
RichardMarks is currently offline  RichardMarks
Messages: 1
Registered: January 2024
Junior Member
Greetings. I would like some assistance with getting clipboard usage sorted out.

My OS is macOS Sonoma 14.2.1 (23C71)
My Hardware is a 2020 M1 Mac mini.

I am using the U++ version downloaded from SourceForge: upp-posix-17045.tar.xz

I have a larger project in which I would like to copy information to the system clipboard for the user to paste into any other app.

I am getting the expected and undesired exclamation message box with the following minimal example.

#include <CtrlLib/CtrlLib.h>

GUI_APP_MAIN
{
    if (!Upp::IsClipboardAvailableText())
    {
        Upp::Exclamation("Clipboard is not available unfortunately");
    }
}


I expect that the following should return true, however, that is not the case.

Upp::IsClipboardAvailableText()


Is the implementation in U++ not compatible with newer macOS?

What are my options?
Re: Clipboard Usage [message #60419 is a reply to message #60409] Fri, 05 January 2024 22:17 Go to previous message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello RichardMarks,

I am not very familiar with Clipboard, but I can assure you that it works. I tested it by copying text from TheIDE to Microsoft Word. I think the method you just mentioned is checking whenever top entry in clipboard is raw text or not. Please keep in mind that there are multiple functions related to clipboard (CtrlCore/CtrlCore.h file - line 1759 to 1817):
void    ClearClipboard();
void    AppendClipboard(const char *format, const byte *data, int length);
void    AppendClipboard(const char *format, const String& data);
void    AppendClipboard(const char *format, const Value& data, String (*render)(const Value& data));
void    AppendClipboard(const char *format, const ClipData& data);
void    AppendClipboard(const VectorMap<String, ClipData>& data);
String  ReadClipboard(const char *format);
bool    IsClipboardAvailable(const char *format);

inline  void WriteClipboard(const char *format, const String& data)
	{ ClearClipboard(); AppendClipboard(format, data); }

void    AppendClipboardText(const String& s);
String  ReadClipboardText();
void    AppendClipboardUnicodeText(const WString& s);
WString ReadClipboardUnicodeText();
bool    IsClipboardAvailableText();

inline  void WriteClipboardText(const String& s)
	{ ClearClipboard(); AppendClipboardText(s); }
inline  void WriteClipboardUnicodeText(const WString& s)
	{ ClearClipboard(); AppendClipboardUnicodeText(s); }

template <class T>
inline void AppendClipboardFormat(const T& object) {
	AppendClipboard(typeid(T).name(), StoreAsString(const_cast<T&>(object)));
}

template <class T>
inline void WriteClipboardFormat(const T& object) {
	ClearClipboard();
	AppendClipboardFormat(object);
}

template <class T>
inline bool ReadClipboardFormat(T& object)
{
	String s = ReadClipboard(typeid(T).name());
	return !IsNull(s) && LoadFromString(object, s);
}

template <class T>
bool IsClipboardFormatAvailable()
{
	return IsClipboardAvailable(typeid(T).name());
}

template <class T>
inline T ReadClipboardFormat() {
	T object;
	ReadClipboardFormat(object);
	return object;
}

Image  ReadClipboardImage();
void   AppendClipboardImage(const Image& img);

inline void WriteClipboardImage(const Image& img)
	{ ClearClipboard(); AppendClipboardImage(img); }

Unfortunately above code is undocumented, but you might learn a lot only from reading functions declaration. Please let me know if it helps.

Klugier


U++ - one framework to rule them all.

[Updated on: Fri, 05 January 2024 22:18]

Report message to a moderator

Previous Topic: Undefined symbols for architecture arm64
Next Topic: Error building upp on Ventura
Goto Forum:
  


Current Time: Tue May 07 21:36:29 CEST 2024

Total time taken to generate the page: 0.02546 seconds