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 18 in printed book and digital formats -- plus a one-year subscription (beginning with 19.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 18.6 ('Git')
Instant purchase and download via GumRoad!

FEATURE

Quick Tip

Toolbars are "special", so you need to subclass them differently

Issue: 18.6 (November/December 2020)
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): 4,722
Starting Page Number: 82
Article Number: 18606
Resource File(s):

Download Icon project18606.zip Updated: 2020-11-02 09:51:25

Related Link(s): None

Excerpt of article text...

I saw a post on the Xojo forum (https://forum.xojo.com/t/event-definition-for-dummies-me/29133/15) basically asking how to show the mouse coordinates when the mouse is in a Toolbar. Now although Toolbar inherits from RectControl, it has no mouse-related events (due to limitations of the operating system, according to the Xojo documentation). So how can we do it?

Michel Budjaret graciously provided a great example showing the use of custom events on a custom Toolbar class (see Figure 1).

While everything is nicely contained in an OOP way, there was just one problem: creating a subclass in the usual way by adding a new class from the insert menu to the project and setting its super to Toolbar results in a Toolbar that does not display the Toolbar editor (where you can add Toolbar buttons to the Toolbar). You can add all your buttons and icons via code.

Now while it is not too difficult to add the Toolbar buttons in code, most people prefer to have a visual representation of the Toolbar in their app (see Figure 2), so they add a standard Toolbar from the menu into their project.

But if you do that, you can't customize that Toolbar with custom events. So to keep the ability to design their Toolbar visually, users have to add all that custom code and properties to the Window which makes it look a bit messy (see Figure 2b).

Do we really have to choose between clean object-oriented code and the ability to design our Toolbar visually?

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