Are you sure beginPath() returns something persistent?

No, I'm not, I'm just guessing where it would make sense to return a path (or subpath, see below).

For example, if you are using this beginPath(), it returns nothing:

void QQuickContext2D::beginPath()

see: https://codebrowser.dev/qt5/qtdeclarative/src/quick/items/context2d/qquickcontext2d.cpp.html#_ZN15QQuickContext2D9beginPathEv

As usual for Qt, the documentation sucks. https://doc.qt.io/qt-5/qml-qtquick-context2d.html#beginPath-method clearly documents beginPath() to return an object. Not what kind of object, or what to expect from it, just an object.

In the very same document, there are several links to http://www.w3.org/TR/2dcontext/, which unfortunately just redirects to a big mess of HTML "living standard". https://html.spec.whatwg.org/multipage/canvas.html#2dcontext seems to be the desired content.

But you do get some value in p1, p2. This may be the current path, previous paths not persisting.

Yes, that matches the behaviour.

Looking again at https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinpath, the example shows a click handler that (partially) draws each clickable object, then invokes isPointInPath() to check if that clickable object contains the mouse coordinates, and finally issues a redraw command, probably to clean up the mess that those checks made.

That does not look very sane and efficient to me. I'll try that.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: [OT] QML Canvas Context2D and mouse input by afoken
in thread [OT] QML Canvas Context2D and mouse input by afoken

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.