Book Image

Learn Red ? Fundamentals of Red

By : Ivo Balbaert
Book Image

Learn Red ? Fundamentals of Red

By: Ivo Balbaert

Overview of this book

A key problem of software development today is software bloat, where huge toolchains and development environments are needed in software coding and deployment. Red significantly reduces this bloat by offering a minimalist but complete toolchain. This is the first introductory book about it, and it will get you up and running with Red as quickly as possible. This book shows you how to write effective functions, reduce code redundancies, and improve code reuse. It will be helpful for new programmers who are starting out with Red to explore its wide and ever-growing package ecosystem and also for experienced developers who want to add Red to their skill set. The book presents the fundamentals of programming in Red and in-depth informative examples using a step-by-step approach. You will be taken through concepts and examples such as doing simple metaprogramming, functions, collections, GUI applications, and more. By the end of the book, you will be fully equipped to start your own projects in Red.
Table of Contents (13 chapters)
11
Assessments

Events and actors

In the previous examples, we saw that most faces can have actors, which are event handlers that execute when a certain event occurs on that face. For example, the slider in the code we just explored has a default on-change actor, which is the code in the last block:

slider 100x20 data 25% [t/text: to-string face/data]

Not all faces can respond to all sorts of events. But a lot of faces can respond to multiple events as well.

Red defines some 40 events for which you can define actors on your faces. You can find the complete list here: https://doc.red-lang.org/en/view.html#_events.

Actors all have short names, such as move, over, or down. If we break them down into categories, we can distinguish the following:

  • mouse events, such as down, up, drag, drop, click, dbl-click, over, wheel, and so on, including events for all three buttons, the mouse wheel, and hovering...