1. Daniel Ferreira
  2. PowerBuilder
  3. Tuesday, 12 November 2024 17:57 PM UTC

Hi guys,

I'm having an issue when the user copies data (text) from whatsapp web and pastes it on a dw column. Seems that text has only ~n, not the usual ~r~n that Windows uses. The problem with that is: when the column has focus, PB doesn't recognize the ~n as a linebreak, but when the column looses focus, it shows the text correctly!!

My thought: intercept the pasting of text, and pre-convert all the '~n' (that are not already ~r~n) to '~r~n'.

I can use the editchanged event, but it is triggered at every keystroke. 

I tried creating an event based on pbm_paste, but it doesn't seem to get triggered when I paste.

So help me please, what event should I use? Or can I check if it was paste on the editchanged event? (either ctrl + V or right click + paste)

 

My whatsapp message, that I copy from Chrome or Edge:

 

The column on my app, when I paste the contents of the message and it has focus:

this is when I hit tab, so the dw loses focus:

If I click on the column again, it goes back to the first view, as if no enters where there.

If I do a pos('~r~n') it returns 0, but pos('~n') returns the positions ok.

If I do a manual "enter" from my keyboard, it inputs a ~r~n, as expected.

Oh, I'm using PB 2022 R3, build 3391. It's the same behavior either using the IDE or building the EXE.

 

Daniel Ferreira Accepted Answer Pending Moderation
  1. Tuesday, 12 November 2024 21:07 PM UTC
  2. PowerBuilder
  3. # 1

Thanks Chris. 
That's what I ended up using. As I mentioned, it has the downside of being triggered at every keystroke, but alas, it worked.

Here's the code, if anyone needs it.

 

Event editChanged of my dw control:

long ll_pos

if isNull(data) or trim(data) = '' then return

// gets the current insertion point in the text
ll_pos = dw_texto.position()

// Fix my text, ie, changes "~n" to "~r~n"
this.object.texto[1] = wf_fixNewLines(data)

// Sets back the insertion point
dw_texto.selectText(ll_pos, 0)

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 12 November 2024 19:03 PM UTC
  2. PowerBuilder
  3. # 2

Hi Daniel;

  Have you tried using the EditChanged event?

Regards .. Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.