KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Implementing Spike in 4D Write Pro
PRODUCT: 4D | VERSION: 16R6 | PLATFORM: Mac & Win
Published On: October 19, 2018

In Microsoft Word, a handy feature for cutting and pasting in a different way is called "Spike". By taking a selection of text, it can be cut by pressing the "Ctrl+F3" keys which is held in memory. Multiple text can be cut into memory. By pressing "Ctrl+Shift+F3" keys the cut selection will be pasted one line at a time. This can be implemented in 4D with the following directions:

1. Copy the following code in the Form object method:

Case of
 :(Form event=On Load)

  Form.workingText:=""
  Form.range:=New object
  Form.spikeCol:=New collection
  Form.pastedText:=""
  Form.pos:=0
  Form.range:=New object

 :(Form event=On Clicked)

  Form.workingText:=ST Get text(*;"WriteProArea";ST Start highlight;ST End highlight)

End case




2. Drop a 4D Write Pro object with sample reference:





3. Drop an invisible button #1

This button will capture the "Ctrl+F3" keystroke in the Property List:



Paste the following code in the button object method:

Form.spikeCol.push(Form.workingText)

ST SET TEXT(*;"WriteProArea";"";ST Start highlight;ST End highlight)




4. Create an invisible button #2

This button will capture the "Ctrl+Shift+F3" keystroke in the Property List:




Paste the following code in the button object method:

C_LONGINT($i)

Form.pastedText:=""

For ($i;0;Form.spikeCol.length-1)
 Form.pastedText:=Form.pastedText+Form.spikeCol[$i]+Char(Carriage Return)+Char(Line Feed)
End for

Form.spikeCol.clear()

Form.range:=WP Get selection(*;"WriteProArea")
WP GET ATTRIBUTES(Form.range;"start";Form.pos)
ST SET TEXT(*;"WriteProArea";Form.pastedText;Form.pos;Form.pos)



Example #1: Cutting and pasting text only:

The green area will cut using "Ctrl+F3":




The green area will paste using "Ctrl+Shift+F3":






Example #2: Cutting and pasting text with picture:

The green area will cut using "Ctrl+F3":




The green area will paste using "Ctrl+Shift+F3":