[Gambas-user] Paste into a textarea

Gianluigi bagonergi at gmail.com
Mon Jan 27 18:39:57 CET 2020


Il giorno lun 27 gen 2020 alle ore 07:16 Bruce <adamnt42 at gmail.com> ha
scritto:

> Hi folks,
>
> Is there any way to check or trap that a textarea has just been pasted
> into?
> It's OK for them to type into it, so the Change event doesn't solve my
> problem, which is I need to clean up the text that has just been pasted.
>
> Bruce
>

I'm not sure I hit the point, see the following code of a TextArea to which
you must have to adapted the paste popup menu:
------------------------------------------------------------------------------
Public Sub TextArea1_KeyPress()

  Dim s As String
  Dim ss As String[]
  Dim iStart, iMinus As Integer
  Dim bExternal As Boolean = True

  If Key.Code = Key["V"] And If Key.Control Then
    'Stop
    Try s = Clipboard.Paste("text/plain;charset=utf-8")
    If Not s Then
      Try s = Clipboard.Paste()
      bExternal = False
    Endif
    Stop Event
    iStart = String.Len(TextArea1.Text)
    ss = Split(s, "\n")
    If bExternal Then
      iMinus = ss.Max
    Else
      iMinus = 0
    Endif
    TextArea1.Text &= s
    TextArea1.Select(iStart, String.Len(s) - iMinus)
  Endif
Catch
  Print Error.Text

End
-------------------------------------------------------------------------------

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200127/3e67bb18/attachment.html>


More information about the User mailing list