{"id":2188,"date":"2021-03-23T19:11:00","date_gmt":"2021-03-23T23:11:00","guid":{"rendered":"https:\/\/anvil-of-time.com\/?p=2188"},"modified":"2021-03-23T10:51:34","modified_gmt":"2021-03-23T14:51:34","slug":"powerbuilder-back-tab-to-last-field-in-datawindow","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-back-tab-to-last-field-in-datawindow\/","title":{"rendered":"PowerBuilder &#8211; Back Tab to Last Field in DataWindow"},"content":{"rendered":"\n<p>An annoyance in a PB window with a datawindow control on it is if you back tab to the dw, your cursor is positioned to the first field and not the last field.  The following technique can eliminate that and make your application a bit more user friendly.<\/p>\n\n\n\n<p>In the Getfocus event of the datawindow:<\/p>\n\n\n<pre><code class=\"language-markup\">long ll_col = 1\nlong ll_pos, ll_x, ll_y, ll_tab\nlong ll_curr_x, ll_curr_y\nstring ls_list, ls_piece, ls_column, ls_setting\n\n\/\/ user back tabbed to get here\nIF Keydown(keyshift!) AND Keydown(keytab!) THEN\n\t\/\/ objects on datawindow\n\tls_list = THIS.object.datawindow.objects + '~t'\n\tDO WHILE ls_list &lt;&gt; ''\n\t\tll_pos = POS(ls_list, '~t')\n\t\tIF ll_pos &gt; 0 THEN\n\t\t\tls_piece = MID(ls_list, 1, ll_pos - 1)\n\t\t\tls_list = TRIM(MID(ls_list, ll_pos + 1))\n\t\t\tIF TRIM(ls_piece) &lt;&gt; '' THEN\n\t\t\t\tls_setting = THIS.Describe(ls_piece + '.Type')\n\t\t\t\tIF UPPER(ls_setting) = 'COLUMN' THEN \/\/ only look at columns\n\t\t\t\t\tls_setting = THIS.Describe(ls_piece + '.Visible')\n\t\t\t\t\t\/\/check for visible only\t\n\t\t\t\t\tIF ls_setting = \"1\"\tTHEN\t\t\t\n\t\t\t\t\t\tls_setting = THIS.Describe(ls_piece + '.X')\n\t\t\t\t\t\tll_x = long(ls_setting)\n\t\t\t\t\t\tls_setting = THIS.Describe(ls_piece + '.Y')\n\t\t\t\t\t\tll_y = long(ls_setting)\n\t\t\t\t\t\tls_setting = THIS.Describe(ls_piece + '.TabSequence')\n\t\t\t\t\t\tll_tab = long(ls_setting) \/\/check tab sequence\n\t\t\t\t\t\tIF ll_tab &gt; 0 AND ((ll_y = ll_curr_y AND ll_x &gt; ll_curr_x) OR (ll_y &gt; ll_curr_y)) THEN\n\t\t\t\t\t\t\tll_curr_x = ll_x\n\t\t\t\t\t\t\tll_curr_y = ll_y\n\t\t\t\t\t\t\tls_column = ls_piece\n\t\t\t\t\t\tEND IF\n\t\t\t\t\tEND IF\n\t\t\t\tEND IF\n\t\t\tEND IF\n\t\tEND IF\n\tLOOP\n\tIF TRIM(ls_column) &lt;&gt; '' THEN\n\t\tTHIS.setrow(long(THIS.Object.DataWindow.LastRowOnPage))\n\t\tTHIS.setcolumn(ls_column)\n\tEND IF\nEND IF<\/code><\/pre>\n\n\n<p>On any given datawindow (if you put this in an ancestor) you need to make sure that any columns you place &#8216;out of view&#8217; are either invisible or have a tab sequence of zero.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An annoyance in a PB window with a datawindow control on it is if you back tab to the dw, your cursor is positioned to the first field and not the last field. The following technique can eliminate that and make your application a bit more user friendly. In the Getfocus event of the datawindow:&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[21,12],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/2188"}],"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=2188"}],"version-history":[{"count":4,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/2188\/revisions"}],"predecessor-version":[{"id":2194,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/2188\/revisions\/2194"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=2188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=2188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=2188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}