{"id":1066,"date":"2020-08-10T10:55:54","date_gmt":"2020-08-10T09:55:54","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=1066"},"modified":"2025-03-31T12:48:59","modified_gmt":"2025-03-31T11:48:59","slug":"detecting-clicks-touches-on-a-page","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/windows-and-pages\/pages\/detecting-clicks-touches-on-a-page","title":{"rendered":"Detecting Clicks\/Touches On A Page"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">PointerPressed<\/h4>\n\n\n\n<p>PointerPressed is a high level function that will be triggered before any control clicked \/ touched gets their Tapped event.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using Windows.UI.Core;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Add to the Page_Loading<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/----- REGISTER FOR THE POINTER PRESSED EVENT SO WE GET ALL SCREEN TOUCHES \/ CLICKS -----\n\tWindow.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Add to the Page_Unloaded<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tWindow.Current.CoreWindow.PointerPressed -= CoreWindow_PointerPressed;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Method that will be called<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/******************************************\n\t\/\/******************************************\n\t\/\/********** PAGE HAS BEEN TAPPED **********\n\t\/\/******************************************\n\t\/\/******************************************\n\t\/\/Will occur for any touch or click anywhere on the page\n\tprivate void CoreWindow_PointerPressed(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.PointerEventArgs args)\n\t{\n\t\ttry\n\t\t{\n\t\t\t\/\/Flag that keypress has been handled (to stop it repeating forever)\n\t\t\targs.Handled = true;\n\n\t\t\t\/\/If you want the touch coordinates\n\t\t\t\/\/txtDebugX.Text = \"X: \" + Convert.ToString(args.CurrentPoint.Position.X);\n\t\t\t\/\/txtDebugY.Text = \"Y: \" + Convert.ToString(args.CurrentPoint.Position.Y);\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tSystem.Diagnostics.Debug.WriteLine(\"Exception: \" + ex.Message);\n\t\t}\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PointerPressed PointerPressed is a high level function that will be triggered before any control clicked \/ touched gets their Tapped event. Add to the Page_Loading Add to the Page_Unloaded Method that will be called<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[115,75],"tags":[],"class_list":["post-1066","post","type-post","status-publish","format-standard","hentry","category-mouse","category-pages"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=1066"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1066\/revisions"}],"predecessor-version":[{"id":1357,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1066\/revisions\/1357"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}