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
:?: how to determine if the user clicks on a text field
-
-
- Offizieller Beitrag
Hi,
this will help (in OnMouseDown event):
Code
Alles anzeigenprocedure 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 -
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:
Codeobj := WPRichText.InputTextFieldName('PAINT_CALC'); obj.Params := 'some display text'; obj.Source := 'some internal text';
when i click on inserted field,
always returns nil
how should i do?
-
- Offizieller Beitrag
Hi,
such fields are single objects. You can use the OnTextObjectClick event for those.
Julian
-
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?
-
Zitat von 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. -
- Offizieller Beitrag
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 https://www.wpcubed.com/forum/viewtopic.php?t=2074 is solved.
Julian