15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

42<br />

Making User Interfaces with Event-Driven Programming<br />

With event-driven <strong>programming</strong>, designing a user interface involves drawing<br />

your user interface and then customizing it by changing its properties. After<br />

you’ve designed your user interface, it will appear to work but it won’t actually<br />

do anything until you write an event handler.<br />

Writing event handlers<br />

The whole purpose of an event handler is to work as a middleman between<br />

your actual program and your program’s user interface. To create an event<br />

handler, you need to identify the following:<br />

✦ A user interface item, such as a button or a check box<br />

✦ The event, such as a click of the mouse<br />

The combination of a user interface item and a specific event uniquely<br />

defines an event handler, as shown in Figure 2-7.<br />

User interface<br />

item (button)<br />

Event<br />

(click)<br />

Figure 2-7:<br />

An event<br />

handler tells<br />

the user<br />

interface<br />

how to<br />

behave<br />

when the<br />

user does<br />

something,<br />

such as<br />

click the<br />

mouse over<br />

a button.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!