{"id":1310,"date":"2012-05-02T17:32:32","date_gmt":"2012-05-02T22:32:32","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=1310"},"modified":"2021-03-11T11:22:04","modified_gmt":"2021-03-11T16:22:04","slug":"powerbuilder-determining-if-controls-overlap","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-determining-if-controls-overlap\/","title":{"rendered":"PowerBuilder &#8211; Determining if Controls Overlap"},"content":{"rendered":"<p>I had a situation where I needed to know if the user is clicking on a control which is underneath a rectangle on a datawindow. In this case the interior of the rectangle was transparent.<\/p>\n<pre name=\"code\" class=\"VB\">ls_name = dwo.name\n\nIF (left(ls_name, 2) = &#039;r_&#039;) THEN \/\/ my standard rectangle naming convention\n\tls_objects = this.Describe( &#039;DataWindow.Objects&#039;)\n\tls_objects = ls_objects + &#039;~t&#039;\n\tll_pos = pos(ls_objects, &#039;~t&#039;)\n\tll_orig_pos = 1\n\tll_ypos = Pixelstounits(ypos, YPixelsToUnits!)\n\tll_xpos = Pixelstounits(xpos, XPixelsToUnits!)\n\t\/\/ loop through objects on datawindow\n\tDO WHILE ll_pos &gt; 0\n\t\tls_object = mid(ls_objects, ll_orig_pos, ll_pos -ll_orig_pos)\n\t\t\/\/ check if pointer is over something behind the rectangle\n\t\tls_x = this.Describe(ls_object + &#039;.X&#039;)\n\t\tls_y = this.Describe(ls_object + &#039;.Y&#039;)\n\t\tls_h = this.Describe(ls_object + &#039;.height&#039;)\n\t\tls_w = this.Describe(ls_object + &#039;.width&#039;)\n\t\t\n\t\tIF NOT ((ll_xpos + 1) &lt;= integer(ls_x)) AND NOT &amp;\n\t\t\t(ll_xpos &gt;= (integer(ls_x) + integer(ls_w))) AND NOT &amp;\n\t\t\t((ll_ypos + 1) &lt;= integer(ls_y)) AND NOT &amp;\n\t\t\t(ll_ypos &gt;= (integer(ls_y) + integer(ls_h))) THEN\n\t\t\t\/\/ cursor position is within boundaries of underlying control\n\t\t\tis_site_location = ls_object\n\t\t\tEXIT\n\t\tEND IF\n\t\tll_orig_pos = ll_pos + 1\n\t\tll_pos = pos(ls_objects, &#039;~t&#039;, ll_orig_pos)\n\tLOOP\nEND IF<\/pre>\n<p>The following link to how to determine if rectangles overlap is <a href=\"http:\/\/stackoverflow.com\/questions\/306316\/determine-if-two-rectangles-overlap-each-other\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had a situation where I needed to know if the user is clicking on a control which is underneath a rectangle on a datawindow. In this case the interior of the rectangle was transparent. ls_name = dwo.name IF (left(ls_name, 2) = &#039;r_&#039;) THEN \/\/ my standard rectangle naming convention ls_objects = this.Describe( &#039;DataWindow.Objects&#039;) ls_objects&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[21,12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1310"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=1310"}],"version-history":[{"count":9,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1310\/revisions"}],"predecessor-version":[{"id":2028,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1310\/revisions\/2028"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=1310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=1310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=1310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}