• Re: http://wpcubed.com/forum/viewtopic.php?p=316#316

    Hi Julian,

    Thanks for the reply and the code. Unfortunately, the code is dependent on there being text beneath the point that the mouse is over.

    I am actually painting images and text to the canvas and these can be painted below any text and also onto new pages where there is no text.

    Is there any way of telling where the mouse is in terms of the pagerect regardless what text is on the page.

    Thanks

    Mark

    • Offizieller Beitrag

    Hi,

    >> Is there any way of telling where the mouse is in terms of the >> pagerect regardless what text is on the page.

    No, there is no way. But a new page always has at least one line of text - at least an empty line of text.

    >> Unfortunately, the code is dependent on there being text beneath the >> point that the mouse is over.

    Thats not 100% correct. It is ok if there is text above the the position or to the right or left side.

    Julian

    PS.: If you reply to a post it will be automatically moved to the top of the list.

  • Hi Julian,

    I'm still trying to get this code to work accurately.

    I have given the user the ability to add images to the rich text canvas. They do this by specifying the position in centimetres. I keep a record of the rect used in centimetres and I apply it to the canvas by converting to twips using wpCentimeterToTwips.

    This works fine. However, when I use your code to try and identify an image under the cursor, I get the following results:

    1. Image on page 1. It miscalculates the top of the image. Quite signifantly too high (say 2 cms). It is fairly accurate on left side except it is perhaps 0.5cm too far left.

    2. Image on 2nd page - nowhere near! Most of the time it cannot find it. Seems rather hit and miss even when I have full pages of text on the 2nd page.

    Having used your code to get x and y positions, I do the following:

    vLeft:=WPCentimeterToTwips(fLeft);
    vTop:=WPCentimeterToTwips(fTop);
    vWidth:=WPCentimeterToTwips(fWidth);
    vHeight:=WPCentimeterToTwips(fHeight);
    if (ax>vLeft) and (ax<vLeft+vWidth)
    and (ay>vTop) and (ay<vTop+vHeight) then
    I've found an image. Any idea why it is not accurate on 1st pages and woefully inaccurate on subsequent pages and what changes I can make to overcome this.

    Regards,

    Mark

    PS Happy New Year