{"id":35,"date":"2007-08-03T10:28:31","date_gmt":"2007-08-03T18:28:31","guid":{"rendered":"http:\/\/www.antunkarlovac.com\/blog\/?p=35"},"modified":"2008-02-22T15:52:08","modified_gmt":"2008-02-22T23:52:08","slug":"the-mouse-wheel-in-openlaszlo","status":"publish","type":"post","link":"https:\/\/www.antunkarlovac.com\/blog\/2007\/08\/03\/the-mouse-wheel-in-openlaszlo\/","title":{"rendered":"The Mouse Wheel in OpenLaszlo"},"content":{"rendered":"<p>In OpenLaszlo, scrollbars don&#8217;t automatically scroll with the mouse wheel. I guess the reason behind this is that scrollbars are very free-form. As a developer, you can make anything scroll, so it would be restrictive if the scrollbars were to respond to mouse wheel events in a predefined way.<\/p>\n<p>To see how to use a scrollbar in OpenLaszlo, see <a href=\"http:\/\/www.antunkarlovac.com\/blog\/?p=3\">my earlier post on the subject<\/a>.<\/p>\n<p>It&#8217;s really easy to trap mouse wheel events in OpenLaszlo. All you do is listen for the <strong>onmouswheeldelta <\/strong>event from the <strong>LzKeys <\/strong>service. That&#8217;s also the service that sends global keyboard events, by the way. The onmouswheeldelta event sends an argument, which tells you how much the wheel moved, and in what direction (it&#8217;s either a positive or a negative number).<\/p>\n<p>To tie this to a scrollbar, you probably want to ensure that the mouse is actually overing above the view you want to scroll. Again, in OpenLaszlo, that&#8217;s really easy. There&#8217;s a <strong>containsPt()<\/strong> method on view, that tells you whether a given point (x,y) is within that view&#8217;s coordinate space. And to find the mouse position in a given views coordinate space, you simply call:<\/p>\n<p><strong>LzView.getMouse(&#8220;x&#8221;) and LzView.getMouse(&#8220;y&#8221;)<\/strong><\/p>\n<p>So here&#8217;s the application in action. Note that you might need to bring focus from the browser to the SWF by clicking once on the SWF:<\/p>\n\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n\t\t\tid=\"fm_mousewheel_415288514\"\n\t\t\tclass=\"flashmovie\"\n\t\t\twidth=\"450\"\n\t\t\theight=\"410\">\n\t<param name=\"movie\" value=\"\/blog\/wp-content\/uploads\/2007\/08\/mousewheel.swf\" \/>\n\t<!--[if !IE]>-->\n\t<object\ttype=\"application\/x-shockwave-flash\"\n\t\t\tdata=\"\/blog\/wp-content\/uploads\/2007\/08\/mousewheel.swf\"\n\t\t\tname=\"fm_mousewheel_415288514\"\n\t\t\twidth=\"450\"\n\t\t\theight=\"410\">\n\t<!--<![endif]-->\n\t\t\n\t<!--[if !IE]>-->\n\t<\/object>\n\t<!--<![endif]-->\n<\/object>\n<p>Enjoy! (Here's the source to a <a href=\"http:\/\/www.antunkarlovac.com\/blog\/wp-content\/uploads\/2008\/02\/mousewheel-example.zip\" title=\"Mouse Wheel Example\">Mouse Wheel Example<\/a>).<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In OpenLaszlo, scrollbars don&#8217;t automatically scroll with the mouse wheel. I guess the reason behind this is that scrollbars are very free-form. As a developer, you can make anything scroll, so it would be restrictive if the scrollbars were to respond to mouse wheel events in a predefined way. To see how to use a &hellip; <a href=\"https:\/\/www.antunkarlovac.com\/blog\/2007\/08\/03\/the-mouse-wheel-in-openlaszlo\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The Mouse Wheel in OpenLaszlo<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/35"}],"collection":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":1,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":228,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/35\/revisions\/228"}],"wp:attachment":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}