Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 22.2 ('Vision Pro')
Instant purchase and download via GumRoad!

COLUMN

Find Yourself

How to determine the location of devices with MBS under Windows and Mac

Issue: 22.2 (March/April 2024)
Author: Stefanie Juchmes-Simonis
Author Bio: Stefanie studied computer science at the university in Bonn. She came in touch with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at Monkeybread Software.
Article Description: No description available.
Article Length (in bytes): 10,226
Starting Page Number: 66
Article Number: 22008
Resource File(s):

Download Icon project-22008.zip Updated: 2024-02-29 23:35:06

Related Link(s): None

Excerpt of article text...

In this article I would like to show you how you can determine the position of your device for Mac and Windows.

Let's start with Windows first. For this purpose, we have the Windows Location topic in the plugin. To determine the position, we need an object based on the WindowsLocationManagerMBS class. For this reason, we create a class in our project that has the WindowsLocationManagerMBS class as a subclass. We start by creating an instance of this class in the LM property. Now we can call the StartEvents method. This method tells the events that they can start working. In this way, we can also work with the LocationChanged event later.

Now we have to make a request for access. We do this with the RequestPermissions method and specify the window in the parameter. In our case, we reference the window in which this method is also used. We can then use the ReportStatus property to query the current status and react to it. There are a total of five different statuses that can be returned. We would like to go through these possible statuses in a Select Case statement. In most cases, a text should be output that shows us what the status is to alert us to possible problems. The status we want is Running. If this status is the result, no text should be output. Instead we wait for the LocationChanged event to fire and provide us with the data for our location.

This is what the code looks like that we have written behind a button to call up the location.

LM = New MyLocationManager

...End of Excerpt. Please purchase the magazine to read the full article.