How to create something like a transparent TextArea

My applications needs a transparent multiline text field that the user can move around in a canvas.

With drawstring I programmed a version, that does this with a single line of the string. The size, color and font type of the text could be set with additional controls.

So I hoped there is a possibility to do this with a textarea too, but the textarea always shows a background.

Does anyone has an idea or an other way to solve this?

Try this in the TextAreas Open event…

[code]Sub Open()

declare sub setDrawBack lib “Cocoa” selector “setDrawsBackground:” (id As integer, b As boolean)
declare function docView lib “Cocoa” selector “documentView” (id As integer) As integer

setDrawBack(me.Handle, false)
setDrawBack(docView(me.Handle), false)

End Sub

The TextAreas Handle points to a XOJScrollView (NSScrollView). You need to turn off background drawing in it and in its documentView which is the actual XOJTextView (NSTextView).

Or using the DrawBlock function of a TEXTAREA… use it to draw the text to a CANVAS and use that to move around with

Just noticed you didn’t specify OS and I assumed :slight_smile: Above only works on mac, afaik the built in TextArea doesn’t have transparency and you’ll need declares, but haven’t tried Daves idea.

I see my assumption now. I thought you wanted an actual TextArea, looks like you just need the drawing. Then use Daves idea and disregard this noise .

It is working now. Thanks to both of you.

Thanks for your idea, the time will come and I or others need your solution too. :slight_smile:

This is the solution:

  dim pict as new Picture(1, 1, 32)
  if areaText.Text <> "" then
    pict = new picture(areaText.Width, areaText.Height)
    dim stp as styledTextPrinter
    stp = areaText.StyledTextPrinter(, pict.Width)
    if stp = nil then
      System.DebugLog("stp = nil")
      stp.DrawBlock(0 , 0, pict.Height)
    end if
  end if

  return pict
End Get

The returned picture is than moved around in the canvas. “areaText” is the Texarea that contains the text that should be moved.