OnTextObjectMouseDown event not triggered with underText img

  • OnTextObjectMouseDown event is not triggered with underText image.

    I have multiple checkboxes, radio buttons and edit fields in my document.

    I also have an image field which has it's underText property set:

    Code
    obj.Mode := obj.Mode + [wpobjObjectUnderText]

    When I click on any fields (text, radio or checkbox) which is not over my image, I receive the following events:

    Code
    OnTextObjectMouseDownOnTextObjectClickOnClick

    When I click on any fields (text, radio or checkbox) which is over my image, I receive the following events:

    Code
    OnTextObjectClick
    OnClick

    Can you please tell me why I don't receive a OnTextObjectMouseDown event on my fields that are displayed over my UnderText image.

    Another problem that I noticed, is that if I have an UnderText image field and I click on this image, I don't receive a OnTextObjectClick event, I only get a OnClick event. This is very important, since I need to detect which image field object that the user has just clicked.

    • Offizieller Beitrag

    Hi,

    I am sorry, I tried that in the latest version.
    I get the click event for TextObjects which are above an "undertext" image.

    It is possible though, that the order in which the objects are painted are different in your case.

    I can modify the code for next version to serach the objects in 2 path, and ignore the undertext images in the first.

    Julian

  • The problem is not with on OnClick event. The problem is that when I click on an image object which is UnderText, it does not trigger the OnTextObjectClick event but only the OnClick event.

    Then, how can I detect the UnderText image object which I just clicked ?

  • What I am trying to do is to detect the TWPTextObj image object, which is in fact a TWPOImage object, that I double clicked on even if this image object is under text and relative to paragraph (mode = [wpobjObjectUnderText, wpobjRelativeToParagraph]).

    If the image object that I create only has the mode property to either wpobjRelativeToParagraph or wpobjObjectUnderText I do receive an OnTextObjectDblClick event. This problem only happens when mode = [wpobjObjectUnderText, wpobjRelativeToParagraph] and I double click on an image object, no OnTextObjectDblClick event gets triggered.

    I know that I can press the shift keyboard key when I double click on the image, but I want the OnTextObjectDblClick event to be triggered with having to press the shitf key.

    Note: this problem happens with WPTools version 5. I don't know if this problem exists with WPTools 6.

  • I did more testing and this problems seems to happen only when TWPTextObj.Mode contains either [wpobjRelativeToParagraph] or [wpobjRelativeToPage].

    If TWPTextObj.Mode contains [wpobjObjectUnderText] only, it works fine.

    Einmal editiert, zuletzt von michelw (1. Februar 2011 um 14:45)

  • I did more testing and here is what I need to accomplish.

    I need to be able to detect the true TWPTextObj object that the user clicked on or double clicked on even if the object is displayed on top of a picture object which is under text.

    With the compiler conditional define DONTREQ_SHIFT_FOR_UNDER_TEXT_OBJ, if I have a picture object that is under text but I also have some checkboxes and radiobuttons objects that appear on top of the picture, the OnTextObjectClick, OnTextObjectDblClick and OnTextObjectMouseDown event will always return me the picture object even if I clicked on a checkbox or a radio button (which I think is not correct).

    Without the compiler conditional define DONTREQ_SHIFT_FOR_UNDER_TEXT_OBJ, which is the default, if I have a picture object that is under text but I also have some checkboxes and radiobuttons objects that appear on top of the picture, the OnTextObjectClick, OnTextObjectDblClick and OnTextObjectMouseDown event will trigger properly when I click on a checkbox or a radio button, but will not trigger when I click on the picture (I guess this is normal since DONTREQ_SHIFT_FOR_UNDER_TEXT_OBJ is NOT defined). If I press the shift key when clicking on a checkbox or a radiobutton, the object clicked on that is returned is NOT the checkbox or radiobutton but the picture.

    What I need to do is to be able to detect which TWPTextObj that the user really clicked on even if the picture is under text and even if some other TWPTextObj objects appear on top of the picture. So if a checkbox appears on top of a picture and the user clicks on this checkbox, I need OnTextObjectClick, OnTextObjectDblClick and OnTextObjectMouseDown to be triggered for checkbox object, but if the user clicks on the picture object, I need OnTextObjectClick, OnTextObjectDblClick and OnTextObjectMouseDown to be triggered for the picture object.

    Essentially, all TWPTextObj objects except picture object should have a higher priority than picture objects when clicked.

    • Offizieller Beitrag

    This apperas to be a special request. You seem to also have special, user defined checkboxes, not the edits which come with wptools.

    I think we should better discuss this in private mail -> support@wptools.de

    In general: TWPTextObj are just text and I think, what You need, You can do in MouseDown event as well if you examine the current position.

  • I don't have any special checkbox. I am using the standard WPTools checkbox. Here is my code that creates a WPTools checkbox and a picture object.

    -When I click on the checkbox, it triggers an OnTextObjectClick event for the checkbox and also an OnClick event, which is correct.

    -When I click on the picture or anywhere else on the page, it only triggers an OnClick event, which is correct.

    -When I press the shift key an click on the picture, it triggers an OnTextObjectClick event for the picture and also an OnClick event, which is correct.

    -When I press the shift key an click on the checkbox, it triggers an OnTextObjectClick event for the picture and also an OnClick event, which is NOT correct because I clicked on the checkbox and not on the picture.


    Now, if I do the same tests but with the DONTREQ_SHIFT_FOR_UNDER_TEXT_OBJ conditional define.


    -When I click on the checkbox, it triggers an OnTextObjectClick event for the picture object and also an OnClick event, which is NOT correct because I clicked on the checkbox and not the picture.

    -When I click on the picture, it triggers an OnTextObjectMouseDown event for the picture and also an OnClick event, which is correct.


    What I need to do is to be able to detect which TWPTextObj that the user really clicked on even if the picture is under text and even if some other TWPTextObj objects appear on top of the picture. So if a checkbox appears on top of a picture and the user clicks on this checkbox, I need OnTextObjectClick, OnTextObjectDblClick and OnTextObjectMouseDown to be triggered for checkbox object, but if the user clicks on the picture object, I need OnTextObjectClick, OnTextObjectDblClick and OnTextObjectMouseDown to be triggered for the picture object.


    I hope that gives you all of the information you need to tell me if this is a problem with WPTools or if you have some other way to make this work.


    Thanks,

    • Offizieller Beitrag

    First - You would not have any problem with a background image if you would paint in as a watermark, or, if it should be saved, place it in the header. I see no reason to put it behind the text like this.


    FORMCHECKBOX is not a check box "object", it is just a symbol which requires code like this to toggle its state. It works a bit differently to an image.

    Code
    procedure TForm1.WPRichText1TextObjectMouseDown(Sender: TWPCustomRtfEdit;  pobj: TWPTextObj; obj: TWPObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  if pobj.Name = 'FORMCHECKBOX' then  begin     WPSetCheckBoxValue(pobj,not WPGetCheckBoxValue(pobj)); // utility function to swap true/false and on/off     WPRichText1.Repaint;  end;end;

    It is true that in this case with a background image the code above does not work. The image uses a fixed rectangle which is checked with priority. That behavior quite difficult to change and usually what You need. Otherwise you could not click on images under the text.

    But using the code below you can bring your checbox to life easily. This is what I meant with "In general: TWPTextObj are just text and I think, what You need, You can do in MouseDown event as well if you examine the current position."