WPCubed Product Support

clicking on merge field vs next to merge field

I use this to determine if the user clicks on a merge field. In the old version, you had to click directly on the field for the event to come back true. In WPT5, if you click a line where the merge field is the last thing, it still comes back true, where it wouldn't before. For example, on a new line, put a merge field as the first thing on the line and nothing else. Click on the far right off the line, well away from the merge field and the event will still come back true.

How can I best emulate the previous function?

These are in the WPTRichText1.MouseUp event.

In WPT4, I had code like this:

var  pa:PTAttr;begin  pa:=WPRichText1.GetAttrAtXY(X,Y);  if (afsAutomatic in ;a^.Style) or (afsIsInsertPoint in pa^.Style) then begin...

in WPT5 I'm dong this:

var
  pa:TWPTextObj;
begin
    pa := DBWPRichText3.FieldAtCP;
    if ( ( pa <> nil ) and ( pa.ObjType=wpobjMergeField ) ) then begin
...

My only work around at this time is to manually place a blank space after the merge field. This stops it, but it's not really something I can expect my customers to do.

#1 ♥ 0
2.8k Views 2 users read 2 min
support

Hi,

FieldAtCP is working correctly since the cursor is really at that field.

You could add a

if ActivePosInPar=ActivaeParagraph.CharCount in your code
to trap the cursor beeing at the end of the line.

Julian

#2 ♥ 0

Ok, I got that to work if the field is the very last thing on the line so that's a big help. Thanks.

Now, how might you deal with it when it's not at the end of the line?

for example:

[mergefield] text text text [mergefield2] text2text2 text2

If you click between the mergfield2 and text2, it will fire.

Is there another way to only make it come back true when clicking directly on the mergefield?

Thanks for your help on this.

#3 ♥ 0
This category is archived. No new posts are possible.