Article Preview
Buy Now
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):
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.