wxTextDataObject(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– wxTextDataObject πŸ’–

okay so bestie, welcome to the wxTextDataObject page πŸŽ€ β€” it's an Erlang module definition, and it's genuinely one of the cutest little clipboard goblins in the whole wx family. come sit with me, we're doing this together 🫢


✨ NAME ✨

wxTextDataObject β€” it's a specialization of wxDataObjectSimple (not implemented in wx) that's all about text data. that's the whole vibe. text. data. object. iconic honestly πŸ’…


🌸 DESCRIPTION 🌸

You can use it as-is to paste data into a wxClipboard or a wxDropSource (not implemented in wx). no changes needed, it just works, slay ✨

Now β€” a user might wanna derive a new class from this one to provide text on-demand, so that memory consumption stays low when you're offering data in several formats (like plain text and RTF, think about it). Why? Because by default the text is stored in a string inside this class... but it might as well be generated when requested. and for that, you'd have to override getTextLength/1 and getText/1. that's the assignment, no cap πŸ“

⚠️ heads up bestie: if you already have the text inside a string, you will not achieve any efficiency gain by overriding these functions. why? because copying wxStrings is already a very efficient operation β€” the data isn't actually copied, since wxStrings are reference counted. so like... don't do extra work for nothing, fr fr πŸ’€

See also, bestie πŸ‘€:

  • Overview dnd
  • wxDataObject
  • wxFileDataObject
  • wxBitmapDataObject

This class is derived, and can use functions, from:

  • wxDataObject

wxWidgets docs: wxTextDataObject


πŸ¦‹ DATA TYPES πŸ¦‹

  • wxTextDataObject() :: wx:wx_object().

that's it. one type. clean. minimal. main character energy πŸ‘‘


🌈 FUNCTIONS 🌈

destroy(This :: wxTextDataObject()) -> ok.

Destroys the object πŸ’€βœ¨ bye bestie, it was real

getText(This) -> unicode:charlist() when This :: wxTextDataObject().

Returns the text associated with the data object πŸ“

You may wish to override this method when offering data on-demand, but this is not required by wxWidgets' internals. Use this method to get data in text form from the wxClipboard. iykyk πŸ’…

getTextLength(This) -> integer() when This :: wxTextDataObject().

Returns the data size πŸ“

By default, it returns the size of the text data set in the constructor or using setText/2. This can be overridden to provide text size data on-demand. It's recommended to return the text length plus 1 for a trailing zero, but this is not strictly required β€” so like, do it, but also, you do you 🫢

new([Option]) -> wxTextDataObject() β€” when Option :: {text, unicode:chardata()}.

The constructor πŸŽ€ may be used to initialise the text (otherwise setText/2 should be used later, no biggie)

setText(This, StrText) -> ok β€” when This :: wxTextDataObject(), StrText :: unicode:chardata().

Sets the text associated with the data object ✨

This method is called when the data object receives the data and, by default, copies the text into the member variable. If you wanna process the text on the fly, you may wish to override this function. go off, customize it bestie πŸ’…πŸ”₯


🧚 tiny reminder for the group chat: all those not implemented in wx notes up top are real, don't come for me, I'm just the messenger 😭

and that's the whole page, bestie!! πŸ’œ this little cutie ships as part of wx 2.6 from Ericsson AB, and the page itself is dated wx 2.6 too. mwah, go paste some text, you're gonna eat πŸ“πŸ‘‘πŸ’–

πŸ“¦ where this page comes from