<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Events declaration
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../cat+en">Up</a>&nbsp;
<a href="event+en">Previous</a>&nbsp;
<a href="eventloop+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Events declaration
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><b>EVENT</b> <u>Name</u> <b>(</b> [ <u>Parameter #1</u> [ <b>,</b> <u>Parameter #2</u> ... ] <b>)</b></pre><p>

This declares a class event. This event is raised by using the <a href="../lang/raise+en">RAISE</a> keyword.
<p>
The <a href="../lang/raise+en">RAISE</a> keyword may return a boolean value to indicate if the event handler wants to cancel the event.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">EVENT BeforeSend(Data AS String) AS Boolean

...

DIM bResult AS Boolean

' Raises the event

bResult = RAISE BeforeSend(&quot;MyData&quot;)

IF bResult THEN
  PRINT &quot;Canceled !&quot;
ENDIF</pre>
<p>
<h2>Event Handler</h2>
<p>
By default, <i>Name_EventName</i> is the name of the method called in the event listener when an event is raised.
<p>
For example, if you have a class called FancyButton and you throw an event called FancyClick, and if in your form called FMain you have a FancyButton object named MyButton, the event handler method would look like this:
<p>
<tt><a href="../lang/public+en">PUBLIC</a> <a href="../lang/sub+en">SUB</a> MyButton_FancyClick(...)</tt>
<p>
The default behavior can be changed somewhat: see <a href="../comp/gb/object+en">Object</a>.<a href="../comp/gb/object/attach+en">Attach</a> and other methods of the static <a href="../comp/gb/object+en">Object</a> class, as well as <a href="../comp/gb.gtk/control+en">Control</a> Groups whose information is applicable to any event-raising class.
<p>
<hr><b>See also</b><br>
<a href="event+en">Event Management</a>&nbsp;

</div>
</body>
</html>

