• Home >>
  • Curl - Developer FAQ - Events
Japanese
Curl, Inc. Logo
Richer Internet Applications
   Developers
      Code Samples
      XML Document Model
      Community
      Books
      FAQ
      Release Notes
         Curl Mac Beta
         Curl RTE 5.0.2
         Curl IDE 5.0.1002
         Curl RTE 4.0.4
         Curl RTE 3.0.10

FAQ - Events

Events 1

How are events delivered?

  2

How are events handled?

  3

I have a PointerPress handler on a VBox (or some other container) but it doesn't fire even when I click in the box. Why not?


 

1 How are events delivered?

Answer:

Some events are delivered to exactly one graphical object. For example, all keyboard events are delivered to the object with the keyboard focus. Selection events are delivered to the object that is being selected or deselected.

Other events are delivered to several objects. The Commit event for example is delivered to the dialog and to each control inside of it.

Pointer events are delivered to the innermost graphic first (if there are overlapping objects, the event goes to the object in front). If that object does not consume the event, it is fired at the containing object and so on, up to the top of the graphic hierarchy.

 

2 How are events handled?

Answer:

You can handle an event on any object by attaching an event handler. This is done using the expression

  {on e:Event at g:Graphic do ...}

or by calling add-event-handler. Events created in this way for a specific instance of a graphic are called "dynamic event handlers."

Many events have a corresponding method called the "static event handler." After the dynamic event handlers are executed for an object, the object's static event handler method is called. By convention, definitions of this method should also include a call to the superclass's static event handler method, so all static event handler methods in the class hierarchy for this event type will be called.

 

3 I have a PointerPress handler on a VBox (or some other container) but it doesn't fire even when I click in the box. Why not?

Answer:

There are a couple of common reasons why event handlers you have added to a Graphic do not run when you expect them to:

  • If a container contains text, then a mouse click on the text will normally start a text selection and will therefore not be seen by an event handler on the text or any of its containers. If you set the nonlocal option text-selectable?=false on the text or its container, then this will not be a problem.

  • Events are not fired on transparent parts of an object unless the opaque-to-events? property is true. If you set the width and height of a container, don't give it a background, and don't put anything inside of it (or put something that doesn't fill the available space), then it may not receive some mouse events. If you add event handlers to an object, make sure at least part of it draws something on the screen. An object will always see mouse events that occur at pixels that it draws.