wxTextDataObject(3erl)

🌸 NAME 🌸

okay so bestie, this is the wxTextDataObject(3erl) page β€” Erlang Module Definition manual vibes β€” and it's literally all about functions for the wxTextDataObject class. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

So wxTextDataObject is a specialization of wxDataObjectSimple (which is not implemented in wx, fyi) for text data. It can be used without change to paste data into the wxClipboard or a wxDropSource (also not implemented in wx). You might want to derive a new class from this class so you can provide text on-demand and keep memory consumption low when you're offering data in several formats β€” plain text and RTF, for example β€” because by default the text is stored in a string inside this class, but it could totally be generated when requested instead. To do that, you'll have to override getTextLength/1 and getText/1. ✨

Quick note, bestie: if you already have the text inside a string, you will not achieve any efficiency gain by overriding these functions, because copying wxStrings is already a very efficient operation (data is not actually copied because wxStrings are reference counted). No cap. 🫢

See: Overview dnd, wxDataObject, wxDataObjectSimple (not implemented in wx), wxFileDataObject, wxBitmapDataObject

This class is derived from β€” and can use functions from β€” wxDataObject.

wxWidgets docs: wxTextDataObject


πŸ’œ DATA TYPES πŸ’œ

  • wxTextDataObject() = wx:wx_object()

πŸ”₯ EXPORTS πŸ”₯

⭐ new() -> wxTextDataObject()

Zero-argument constructor moment. πŸ’–

🌈 new(Options :: [Option]) -> wxTextDataObject()

Types:

  • Option = {text, unicode:chardata()}

This constructor can be used to initialise the text β€” otherwise setText/2 should be used later. πŸŽ€

πŸ¦‹ getTextLength(This) -> integer()

Types:

  • 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 is recommended to return the text length plus 1 for a trailing zero, but this is not strictly required. 🫢

πŸ‘‘ getText(This) -> unicode:charlist()

Types:

  • 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. πŸ’…

πŸ“ setText(This, StrText) -> ok

Types:

  • 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 want to process the text on the fly you may wish to override this function. πŸŽ€

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

Destroys the object. bye bestie πŸ’€πŸ’–


Signed off with love by the wxWidgets team 🫢 β€” this page is rockin' wx 2.2.2.1, and you've been reading wxTextDataObject(3erl). periodt. πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from