wxTextDataObject(3)
π 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 copyingwxStrings is already a very efficient operation β the data isn't actually copied, sincewxStrings are reference counted. so like... don't do extra work for nothing, fr fr π
See also, bestie π:
- Overview dnd
wxDataObjectwxFileDataObjectwxBitmapDataObject
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
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms