Home 01: Example - Button
Content
Cancel

01: Example - Button

In this example we want to create a class for a button. Buttons are used often, so it is a perfect example to make it reusable. The button should know its position, its size and the text to display. And it should be able to check if a specific x and y position is inside its boundaries.

Inheritance

Next, we want to use inheritance to create a BlueButton that inherits everything from our original Button, but has a blue background.

Callback

Lastly, we want to combine what we have learned about callbacks with our Button class.

This post is licensed under CC BY 4.0 by the author.
Contents