1. Tracy Lamb
  2. PowerBuilder
  3. Monday, 12 September 2022 22:33 PM UTC

Hi all,

I've got a dw that I want to over-ride the default Windows paste behavior on.  In my dw the user can copy (CTRL+C) a value, then highlight several rows and paste (CTRL+V).  I have an event ue_keypress for the keypress event, and trap CTRL+V.  If CTRL+V is pressed, I trigger the pfc_paste event. 

CHOOSE CASE key
	CASE KeyV!
		if (keyflags = 2) then
			this.Event pfc_paste()
			return 1
		end if

The pfc_paste event works perfectly, but before the keypress event triggers Windows "automagically" pastes what's in the clipboard to the last row selected, then pfc_paste() runs.  I tried replacing this.Event with this.TriggerEvent .... no luck.  It normally wouldn't be a problem except that pfc_paste checks to see if something is in the cell first. If there is something, it prompts the users for an over-write.  So, the way it is now, the user gets prompted on the last row every time, even though the value was initially blank (before Windows pasted the clipboard into the cell).

Thanks,
~~~Tracy

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 13 September 2022 00:08 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Tracy;

  One easy way is to created menu items (can be hidden) for the CTRL+V/C shortcuts. Then code the enhanced behaviour that you need from there (or call different User Events on the DC where you need to implement your paste behaviour variations.  HTH

Regards... Chris 

 

Comment
  1. Tracy Lamb
  2. Tuesday, 13 September 2022 01:16 AM UTC
Thanks Chris. I added Paste (CTRL-V) to the main menu. Not visible, but enabled. Call of_SendMessage("pfc_paste") from the menu item. Works like a charm! In dw's where I don't have pfc_paste code, it works like normal Windows paste function.

~~~Tracy
  1. Helpful
  1. Tracy Lamb
  2. Tuesday, 13 September 2022 01:18 AM UTC
PS: I also deleted the Case KeyV! code.

  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 13 September 2022 01:59 AM UTC
That's awesome Tracy! :-)
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 13 September 2022 01:17 AM UTC
  2. PowerBuilder
  3. # 1

Hi, Tracy -

Your app is built upon the PFC, so the window/sheet menu likely contains a menu item keyed to Ctrl+V that has the message router trigger a pfc_paste event. PFC Windows don't normally contain a pfc_paste event. If yours does not, the message router will then try to trigger the pfc_paste event in the DataWindow Control that has input focus. If your DWC is descended from u_dw, it does contains a pfc_paste event.

You shouldn't need to intercept and handle a Ctrl+V key sequence, since the PFC infrastructure does so for you.

You should be able to override the pfc_paste event in the DWC to perform the functionality you require. In the override, if you need to invoke the ancestor event script, you can do via the Super pronoun. If you want the window to handle the pfc_paste event, all you need to do is create an unmapped user event named pfc_paste in the window.

Best regards, John

Comment
  1. Tracy Lamb
  2. Tuesday, 13 September 2022 01:24 AM UTC
Yes... after implementing Chris's suggestion, I deleted the Case KeyV! code.
  1. Helpful
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.