{"id":51369,"date":"2021-01-10T03:01:37","date_gmt":"2021-01-09T17:01:37","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=51369"},"modified":"2021-01-11T08:00:32","modified_gmt":"2021-01-10T22:00:32","slug":"multipurpose-buttons-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/multipurpose-buttons-primer-tutorial\/","title":{"rendered":"Multipurpose Buttons Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/multipurpose_buttons.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Multipurpose Buttons Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/multipurpose_buttons.jpg\" title=\"Multipurpose Buttons Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Multipurpose Buttons Primer Tutorial<\/p><\/div>\n<p>At this blog we go <a target=_blank title='?' href='https:\/\/www.google.com\/search?q=hard+quiz&#038;rlz=1C5CHFA_enAU832AU832&#038;oq=hard+quiz&#038;aqs=chrome..69i57j69i60j69i65l3j69i61j69i60l2.1883j0j4&#038;sourceid=chrome&#038;ie=UTF-8'>hard<\/a> at spruiking the qualities of HTML dropdown (ie. select) elements to do with &#8230;<\/p>\n<ul>\n<li>the display brevity &#8230; as well as &#8230;<\/li>\n<li>richness of content possibilities<\/li>\n<\/ul>\n<p> &#8230; they can infer upon a webpage.  At the expense of &#8220;the display brevity&#8221; we are keen to use a dropdown attribute &#8220;size&#8221; set so as to display all the content on the screen where &#8230;<\/p>\n<ul>\n<li>it can sensibly fit on the screen &#8230; and &#8230;<\/li>\n<li>it does not matter that mobile platforms do not recognize the &#8220;size&#8221; attribute &#8220;vertical expansion&#8221; of a dropdown that takes place on non-mobile platforms<\/li>\n<\/ul>\n<p>Today, though, we&#8217;re here to show you that, with a bit of Javascript event logic, a &#8230;<\/p>\n<ul>\n<li>button element &#8230; even better than an &#8230;<\/li>\n<li>input type=button element<\/li>\n<\/ul>\n<p> &#8230; can go some of the way to mimicking those qualities we like so much above, doing even better than the x (ie. horizontal) dimension limit of one that a dropdown has, to be able to fit more data content in horizontally, as a display mechanism you might say has &#8220;the display brevity&#8221; combined with content complexity you are after.<\/p>\n<p>We wrote a proof of concept <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/multipurpose_buttons.html-GETME\" title=\"multipurpose_buttons.html\">multipurpose_buttons.html<\/a>, featuring the one Javascript &#8220;onclick&#8221; logic function as per &#8230;<\/p>\n<p><code><br \/>\n var x=0, y=0, lastx=0,lasty=0;<br \/>\n var propx=0.0, propy=0.0;<br \/>\n<br \/>\n function iclicked(event) {<br \/>\n   var rectis=null, isok=true;;<br \/>\n   if (('' + event.target.id) == 'bxandy') {<br \/>\n       setTimeout(agval, 1000);<br \/>\n   } else if (('' + event.target.className) == 'bxandy') {<br \/>\n       setTimeout(agval, 1000);<br \/>\n   } else if (('' + event.target.id) == 'bx') {<br \/>\n       setTimeout(agval, 1000);<br \/>\n   } else if (('' + event.target.className) == 'bx') {<br \/>\n       setTimeout(agval, 1000);<br \/>\n   } else if (('' + event.target.id) == 'ixandy') {<br \/>\n       rectis=event.target.getBoundingClientRect();<br \/>\n       if (event.touches) { \/\/ thanks to https:\/\/stackoverflow.com\/questions\/24567441\/how-do-i-detect-two-fingers-at-touchstart-in-javascript<br \/>\n         if (event.touches.length &gt; 1) {  isok=false; }<br \/>\n       }<br \/>\n       if (isok) {<br \/>\n       if (event.touches) {<br \/>\n         var touches1 = event.changedTouches;<br \/>\n         var first1 = touches1[0];<br \/>\n         x = first1.clientX;<br \/>\n         y = first1.clientY;<br \/>\n       } else if (event.clientX || event.clientY) {<br \/>\n       x = event.clientX; \/\/ - elemLeft;<br \/>\n       y = event.clientY; \/\/ - elemTop;<br \/>\n       } else {<br \/>\n       x = event.pageX; \/\/ - elemLeft;<br \/>\n       y = event.pageY; \/\/ - elemTop;<br \/>\n       }<br \/>\n       lastx=x;<br \/>\n       lasty=y;<br \/>\n       propx=eval(eval(x - rectis.x) \/ rectis.width);<br \/>\n       propy=eval(eval(y - rectis.y) \/ rectis.height);<br \/>\n       if (eval(propx) &lt;= 0.333 && eval(propy) &lt;= 0.333) {<br \/>\n         gval='1';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &gt;= 0.666 && eval(propy) &lt;= 0.333) {<br \/>\n         gval='3';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propy) &lt;= 0.333) {<br \/>\n         gval='2';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.333 && eval(propy) &lt;= 0.666) {<br \/>\n         gval='4';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &gt;= 0.666 && eval(propy) &lt;= 0.666) {<br \/>\n         gval='6';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propy) &lt;= 0.666) {<br \/>\n         gval='5';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.333) {<br \/>\n         gval='7';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &gt;= 0.666) {<br \/>\n         gval='9';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else {<br \/>\n         gval='8';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       }<br \/>\n       }<br \/>\n   } else if (('' + event.target.id) == 'ix') {<br \/>\n       rectis=event.target.<a target=_blank title='getBoundingClientRect' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Element\/getBoundingClientRect'>getBoundingClientRect()<\/a>;<br \/>\n       if (event.touches) { \/\/ thanks to https:\/\/stackoverflow.com\/questions\/24567441\/how-do-i-detect-two-fingers-at-touchstart-in-javascript<br \/>\n         if (event.touches.length &gt; 1) {  isok=false; }<br \/>\n       }<br \/>\n       if (isok) {<br \/>\n       if (event.touches) {<br \/>\n         var touches1 = event.changedTouches;<br \/>\n         var first1 = touches1[0];<br \/>\n         x = first1.clientX;<br \/>\n         y = first1.clientY;<br \/>\n       } else if (event.clientX || event.clientY) {<br \/>\n       x = event.clientX; \/\/ - elemLeft;<br \/>\n       y = event.clientY; \/\/ - elemTop;<br \/>\n       } else {<br \/>\n       x = event.pageX; \/\/ - elemLeft;<br \/>\n       y = event.pageY; \/\/ - elemTop;<br \/>\n       }<br \/>\n       lastx=x;<br \/>\n       lasty=y;<br \/>\n       propx=eval(eval(x - rectis.x) \/ rectis.width);<br \/>\n       propy=eval(eval(y - rectis.y) \/ rectis.height);<br \/>\n       if (eval(propx) &lt;= 0.111) {<br \/>\n         gval='1';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.222) {<br \/>\n         gval='2';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.333) {<br \/>\n         gval='3';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.444) {<br \/>\n         gval='4';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.555) {<br \/>\n         gval='5';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.666) {<br \/>\n         gval='6';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.777) {<br \/>\n         gval='7';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else if (eval(propx) &lt;= 0.888) {<br \/>\n         gval='8';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       } else {<br \/>\n         gval='9';<br \/>\n         setTimeout(agval, 1000);<br \/>\n       }<br \/>\n       }<br \/>\n   }<br \/>\n }<br \/>\n<br \/>\n function agval() {<br \/>\n   if (gval != '') {<br \/>\n      alert('You clicked ' + gval);<br \/>\n      gval='';<br \/>\n   }<br \/>\n }<br \/>\n<\/code><\/p>\n<p> &#8230; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/multipurpose_buttons.html\" title=\"Click picture\">live run<\/a> linked web application you can try for yourself regarding this, or see, in action, below &#8230;<\/p>\n<p><iframe style='width:90%;height:670px;' title='Proof of concept' src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/multipurpose_buttons.html'><\/iframe><\/p>\n<p><b><i>Did you know?<\/i><\/b><\/p>\n<p>Regarding the input type=button &#8220;Horizontal and Vertical Dimensions&#8221; element &#8220;look&#8221; above we needed help from the internet, thanks, to stop some web browsers such as Firefox, Chrome and Opera not &#8220;fattening out&#8221; the element height so as to show three lines of numbers, as per the CSS (thanks to <a target=_blank title='Useful link, thanks' href='https:\/\/stackoverflow.com\/questions\/10743763\/word-wrap-break-word-does-not-work-in-this-example'>html &#8211; word-wrap break-word does not work in this example &#8211; Stack Overflow<\/a> and <a target=_blank title='Useful link, thanks' href='https:\/\/stackoverflow.com\/questions\/13048499\/wrapping-an-html-input-buttons-text-value-over-multiple-lines'>Wrapping an HTML input button&#39;s text value over multiple lines &#8211; Stack Overflow<\/a> and <a target=_blank title='Useful link, thanks' href='https:\/\/stackoverflow.com\/questions\/5419086\/button-height-on-chrome'>html &#8211; Button height on Chrome &#8211; Stack Overflow<\/a>) &#8230;<\/p>\n<p><code><br \/>\n&lt;style&gt;<br \/>\n #ixandy {<br \/>\n   font-size: 12px;<br \/>\n   width: 36px;<br \/>\n   height: 44px;<br \/>\n<br \/>\noverflow-wrap: break-word;<br \/>\nword-wrap: break-word;<br \/>\n<br \/>\n-ms-word-break: break-all;<br \/>\n\/* This is the dangerous one in WebKit, as it breaks things wherever *\/<br \/>\nword-break: break-all;<br \/>\n\/* Instead use this non-standard one: *\/<br \/>\nword-break: break-word;<br \/>\n<br \/>\n\/* Adds a hyphen where the word breaks, if supported (No Blink) *\/<br \/>\n-ms-hyphens: auto;<br \/>\n-moz-hyphens: auto;<br \/>\n-webkit-hyphens: auto;<br \/>\nhyphens: auto;<br \/>\n<br \/>\n  white-space: normal;<br \/>\n<br \/>\n  box-sizing: content-box;<br \/>\n  -moz-box-sizing: content-box;<br \/>\n  -ms-box-sizing: content-box;<br \/>\n  -webkit-box-sizing: content-box;<br \/>\n }<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d51369' onclick='var dv=document.getElementById(\"d51369\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/onclick\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d51369' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>At this blog we go hard at spruiking the qualities of HTML dropdown (ie. select) elements to do with &#8230; the display brevity &#8230; as well as &#8230; richness of content possibilities &#8230; they can infer upon a webpage. At &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/multipurpose-buttons-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[174,281,327,367,400,2208,576,609,652,861,997,1986,1209,1319],"class_list":["post-51369","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-button","tag-css","tag-did-you-know","tag-dropdown","tag-event","tag-getboundingclientrect","tag-html","tag-input","tag-javascript","tag-onclick","tag-programming","tag-proof-of-concept","tag-style","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/51369"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=51369"}],"version-history":[{"count":20,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/51369\/revisions"}],"predecessor-version":[{"id":51397,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/51369\/revisions\/51397"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=51369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=51369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=51369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}