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 17.2 ('Barchart API')
Instant purchase and download via GumRoad!

COLUMN

Creating Custom Events

Adding events to your classes

Issue: 17.2 (March/April 2019)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 9,362
Starting Page Number: 53
Article Number: 17208
Resource File(s):

Download Icon project17208.zip Updated: 2019-03-04 09:41:43

Related Link(s): None

Excerpt of article text...

If you've been using Xojo for even a little while, you're accustomed to handling events. Pretty much any control you put on a window generates events, which is how the rest of your program learns that the user clicked a button or typed something. But even long-time users of Xojo may not have explored creating their own events.

Did you even realize you can make your own events? It's there in the interface of the IDE, but exactly how you do it isn't obvious. The documentation doesn't make it crystal clear, either. I know it took me a few years to start using events.

Today let's explore this process in more detail.

A Custom Class (or Subclass)

The first thing you need to know about adding your own events is that you can only add them to classes or subclasses. You add the definition in the class, and then you add a handler for doing something with the event within its subclass.

This is most clearly shown when you're working with a control. Controls naturally have events as they respond to the user using them. So the simplest example of a custom event is to create our own control.

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