Article Preview
Buy Now
COLUMN
Column
Issue: 14.1 (January/February 2016)
Author: Markus Winter
Author Bio: Markus is a Molecular Biologist who taught himself REALbasic programming in 2003 to let the computer deal with some exceedingly tedious lab tasks. Some call it lazy, he thinks it smart. He still thinks of himself as an advanced beginner at best.
Article Description: >No description available
Article Length (in bytes): 16,200
Starting Page Number: >9
Article Number: 14114
Related Link(s): None
Excerpt of article text...
You might be wondering why you haven't seen any tips about Xojo's Web Edition in this column. Well, there's a simple reason for it: I have no clue about Web Edition. I only have an old expired license for it, and I don't use it. Yet. So I'm completely dependent on our readers to send in their tips. Michel Bujardet has not only done so for our first tip, but he came up with a whopper: tap into the potential of JavaScript to enhance the power of Xojo's Web edition.
Tip 1: JRSwhere: Get the mouse cursor location in Xojo Web
Unlike Desktop, Xojo Web does not have
System.MouseX
andSystem.MouseY
to report the location of the mouse cursor. The only available way is to use theMouseMove
event. Unfortunately, that event requires a round trip between the server and client for every pixel, which means such a huge amount of traffic it may very well overflow the app. As a result, most developers avoid using that event and have to resort to much less precise techniques, such as usingMouseEnter
andMouseExit
.Here is a technique that uses JavaScript to record client side (in the browser), the position of the mouse. So, when needed, a simple call to a method reports
X
andY
.Everything starts with a custom control, created with the help of the WebSDK. You will find the WebSDK documentation in the same folder as the Xojo IDE, inside the Extra subfolder. The WebSDK is a very powerful set of tools that will let you add features to your web apps "the proper way." Here is how you build a class that will execute JavaScript and report the returned values through an event.
- Insert a new class into your project (Insert menu). Set its name in the Inspector to
JSR (stands for JavaScript Return [value]).
...End of Excerpt. Please purchase the magazine to read the full article.