You can write farSlang event handler procs to modify the operation of topics and farVIEW windows. You have two ways to link event handlers to window events: use the <script> tag in a farVIEW form, or write farSlang code to associate an event with a farSlang proc using the CWindow.SetEventProc API. Let's look at a simple example of the latter.
The following example farSlang module creates a window containing a
button. The module links the onClick event of the button to an event
handler proc, called clicker, within the module. When you click
the button, the event handler proc sounds a beep. We'll include a frame
for the window so that you can close it using the Xit-box in the upper-right
corner of the window.
module example
glb System: CSystem -- Event handler to beep when the button is clicked
-- Initialization code begins here -- Create the main window and its button
-- Link the button onClick event to the clicker proc
-- Make the window visible
|
I should note that the clicker event handler proc does not need to be in the example module, it could be in any farSlang module. However, the farVIEW implementation does require that all the event handlers for a given window tree must reside in a single module.
Here is the same example as a XUL script with a farSlang event handler:
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script language="text/farSlang"> proc clicker beep endProc clicker </script> <button label="Click Me" onclick="clicker"/>' </window> |
Here is a table of the farVIEW events that you can link to farSlang
window event handlers:
|
|
|
the Abort button is clicked |
|
the window loses focus |
|
the Cancel button is clicked |
|
a button is clicked |
|
the window is closing |
|
a command key is pressed (Fun, Alt, or Ctrl) |
|
the default button is clicked |
|
the LMB is double clicked |
|
the Enter key is pressed |
|
the window gains focus |
|
the Ignore button is clicked |
|
a key is enetered |
|
the LMB is pressed |
|
the LMB is released |
|
the mouse enters the window |
|
the mouse leaves the window |
|
the mouse moves within the window |
|
the No button is clicked |
|
the Ok button is clicked |
|
the window is opening |
|
the Retry button is clicked |
|
the Return (Enter) key is pressed |
|
the RMB is pressed |
|
the RMB is released |
|
a checkbox or radiobutton is set to on |
|
the Yes button is clicked |