4D Write v14

WR GET CURSOR POSITION

Home

 
4D Write v14
WR GET CURSOR POSITION

WR GET CURSOR POSITION 


 

WR GET CURSOR POSITION ( area ; page ; column ; line ; position ) 
Parameter Type   Description
area  Longint in 4D Write area
page  Longint in Number of the page where the selection is
column  Longint in Number of the column where the selection is
line  Longint in Number of the line in the column
position  Longint in Position of the selection in the current line

The WR GET CURSOR POSITION command returns the position of the selection in the 4D Write area referenced by area.

  • page: page is between the number of the first page and the number of the last page of the document. These numbers take into account the custom page numbering, if any.
  • column: This value is between 1 and the total number of columns.
  • line: This value is between 1 and the total number of lines in the column.
  • position: This value is between 1 and the total number of characters in the line.

If the selection contains several characters, the position of the first character is returned.
You can later go back to this location, using the WR SET CURSOR POSITION command with the same parameters.
You can use WR Get frame to determine which area the cursor is in.

Example  

You want the user to be able to insert a logo in the header of the document, without losing the current position of the cursor in the text. To do this, attach the following method to the insertion button:

 C_LONGINT($frame;$Col;$Line;$Pos)
 C_REAL($PictWidth;$PictHeight;$OrigWidth;$OrigHeight;$HeadTopMargin)
  `Which frame of the document is the cursor in?
 $frame:=WR Get frame(Area)
  `Getting current cursor position
 WR GET CURSOR POSITION(Area;$Page;$Col;$Line;$Pos)
  `Switching the current area to the header of the document
 WR SET FRAME(Area;wr right header)
  `Loading the record that contains the logo to include
 ALL RECORDS([Interface])
  `Inserting the logo
 WR INSERT PICTURE(Area;[Interface]Logo;0)
  `Selecting the logo and getting its size
 WR SELECT(Area;4;1)
 WR GET PICTURE SIZE(Area;$PictWidth;$PictHeight;$OrigWidth;$OrigHeight)
  `The height of the header must fit the picture
 $HeadTopMargin:=WR Get doc property(Area;wr header top margin)
 WR SET DOC PROPERTY(Area;wr text top margin;$HeadTopMargin+$PictHeight)
 WR SET DOC PROPERTY(Area;wr header bottom margin;$PictHeight)
  `Then going back to the frame the cursor was in
 WR SET FRAME(Area;$frame)
  `Putting the cursor back in its original position
 WR SET CURSOR POSITION(Area;$Page;$Col;$Line;$Pos)

 
PROPERTIES 

Product: 4D Write
Theme: WR Area Options
Number: 89461

 
HISTORY 

Created: 4D Write 6.5

 
SEE ALSO 

WR GET CURSOR COORDINATES
WR Get frame
WR SET CURSOR POSITION

 
ARTICLE USAGE

4D Write Language ( 4D Write v11.6)
4D Write Language ( 4D Write v12)
4D Write Language ( 4D v13)
4D Write Language ( 4D Write v14)
4D Write Language ( 4D Write v14 R2)
4D Write Language ( 4D Write v14 R3)
4D Write Language ( 4D Write v14 R4)