Skip to content

Improving Copy/Paste with Text

As you are undoubtedly aware, Xojo does not expose your source code as one big blob of text. That makes it tricky to copy code from Xojo or into Xojo from or to outside sources such as blog posts or LLM AI chats. Starting with 2026r2 we’ve made this easier.

Copying

Copying individual members (methods, properties, etc.) from a project item continues to work as before. However, we have added the ability for you to copy some entire project items out of Xojo as text.

Note: When copying a project item (or a member), the Navigator, not one of the editors, must have focus. You can tell it has focus by its color, which is non-gray (green on macOS, for example).

For example, you can select a class (or module or interface) and then paste its contents as text into your favorite text editor, blog editor or AI chat. As an example, here is the DataPoint class (from the Desktop Eddie’s Electronics example project) copied as text and pasted into this post:

Class DataPoint
  Public Sub Constructor(value as Integer, shape as Integer = 0)
    Self.Value = value
    Self.Shape = shape
  End Sub

  Public Function PointNearby(x as integer, y as integer, tolerance as integer = 10) As Boolean
    If Abs(x-Self.x) < tolerance And Abs(y-Self.y) < tolerance Then
      Return True
    End If
  End Function

  Public Property Label As String

  Public Property Shape As Integer

  Public Property Value As Integer

  Public Property X As Integer

  Public Property Y As Integer

End Class

This is surprisingly handy and is a great way to share your code outside Xojo. You can also select multiple project items at once, plus it works with layouts such as Windows, WebPages, Screens and Containers.

Pasting

Pasting code into Xojo has even more improvements. Previously you could paste single members (Methods, Enums, etc., but not properties) into a project item. Now you can paste multiple members at once, including properties. For example, select and copy the list of properties below and paste them onto a project item.

Note: When pasting the project item, the Navigator, not one of the editors, must have focus. You can tell it has focus by its color, which is non-gray (green on macOS, for example).

Public Property Company As String
  Private Property Country As String
Property Address As String
Public Property City As String

Public Property State As String // State code

You can even have different types of members in the selected text, like this:

Public Property Taxable As Boolean
Get
  Const kMax = 42
  Return False
End Get
Set
  Company = "TaxMan”
  Const kMin = 0
End Set
End Property
Public Property Company As String


Public Function Average(A As Double, B As Double) As Double
  Return (A + B) / 2
End Function

And taking things a step further, you can even paste in an entire class:

Class Calculator
  Public Sub Calc()
    Var i As Integer
  End Sub

End Class

Go ahead and copy the DataPoint class from the top and trying pasting it into a project.

And yes, you can also have multiple classes in the selected text:

Class Test
  Public Sub Hello()
    MessageBox("Hello")
  End Sub

End Class

Class Foo
  Public Sub Bar()
    Var i As Integer
  End Sub

End Class

If you paste in a block of text that is not recognized as Xojo code, it is inserted into a new Note, which is a quick way to get some docs added to your classes.

This pasting of project items works for classes, interfaces and non-nested modules. Now when an LLM creates a class for you, you can easily select the entire thing and paste it to add it to your Xojo project!

Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at Goto 10 and on Mastodon @lefebvre@hachyderm.io.