WPCubed Product Support

:?: how to determine if the user clicks on a text field

I insert some fields by using 'InputMergeField' function to a document. I want to know if the user clicks on the fields. but the event 'OnTextObjectMouseDown' does not fire when user clicks between the begin position and end position of that field. when user clicks on the begin position or end position, this event works as expected. how to fire the 'OntextObjectMouseDown' event when user clicks between the begin and end?

thanks a million

#1 ♥ 0
7.1k Views 1 links 3 users read 3 min
support

Hi,

this will help (in OnMouseDown event):

procedure TWPRepTest.WPRichText1MouseDown(Sender: TObject; 
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 
var pobj: TWPTextObj; 
    par: TParagraph; 
    posinpar: Integer; 
    s : string; 
begin 
  if Button = mbRight then 
  begin 
    pobj := WPRichText1.CodeInsideOf(x, y, wpobjMergeField, par, posinpar); 
    if pobj <> nil then 
    begin 
      s := pobj.Name; 
      if InputQuery('Field Properties', 'Name', s) then 
        pobj.Name := s; 
    end; 
  end; 
end;

Julian

#2 ♥ 0

yes, this code works, but i found it does not work for calculate fields.

i insert a calculate field into WPRichText using the following code:

obj := WPRichText.InputTextFieldName('PAINT_CALC');  obj.Params := 'some display text';  obj.Source := 'some internal text';

when i click on inserted field,

pobj := WPRichText1.CodeInsideOf(x, y, wpobjTextObject, par, posinpar);

always returns nil

how should i do?

#3 ♥ 0
support

Hi,

such fields are single objects. You can use the OnTextObjectClick event for those.

Julian

#4 ♥ 0

i tried, it seems working, but not always.

i want to make one menu item visible when right click on such a field, so i add code to 'OnTextObjMouseDown' Event, when i right click the field, sometimes the event fires but sometimes not. I think it is the same as another problem, that is when mouse move over the field, the cursor not always switch to a hand.

is there another way to solve this problem?

#5 ♥ 0

@littlegg:
i want to make one menu item visible when right click on such a field, so i add code to 'OnTextObjMouseDown' Event, when i right click the field, sometimes the event fires but sometimes not. I think it is the same as another problem, that is when mouse move over the field, the cursor not always switch to a hand.

I have the same problem.

#6 ♥ 0
support

Hi,

From Version 5.20.5 the cursor positioning algorithm was slightly change to check for clicks on textobjects better. Itr does not use the margin it uese for regular characters. For regular characters this margin is required to make selection with the mouse and positioning of the cursor easier so [](http://www.wpcubed.com/forum/viewtopic.php?t=2074) is solved.

Julian

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