GLG Toolkit, Java Class Library  Version 4.6
Listeners and Callbacks

Detailed Description

Functions

Object AddListener (int listener_type, Object listener)
 Adds an event listener to the bean. More...
 
void HCallback (GlgObject viewport)
 H callback. More...
 
void HierarchyCallback (GlgObject top_viewport, GlgHierarchyData hierarchy_info)
 Hierarchy callback. More...
 
void InputCallback (GlgObject vp, GlgObject message_obj)
 Input callback. More...
 
void ReadyCallback (GlgObject viewport)
 Ready callback. More...
 
void SelectCallback (GlgObject vp, Object[] name_array, int button)
 Select callback. More...
 
void Trace2Callback (GlgObject top_viewport, GlgTraceData trace_info)
 This method is invoked to handle any events in the bean's drawing and may be overridden by bean's subclasses to implement custom event handling logic. More...
 
void TraceCallback (GlgObject top_viewport, GlgTraceData trace_info)
 Trace callback. More...
 
void VCallback (GlgObject viewport)
 V callback. More...
 

Function Documentation

◆ AddListener()

Object AddListener ( int  listener_type,
Object  listener 
)

Adds an event listener to the bean.

Only a single event listener for each listener type is enabled. Setting a new event listener overrides any previous settings. Hierarchy listener must be attached before loading the bean's drawing.

By default, the bean itself is used as a listener for all GLG events; adding a listener disables the corresponding event-handling callback of the bean (for example, adding the INPUT_CB listener disables the bean's InputCallback). Therefore, the application must use only one type of the event handling: either a bean's callback or a listener.

The bean's callback method is usually used for applications which subclass the bean to provide different event-handling functionality for derived classes.

Parameters
listener_typeThe type of listener to add. May be one of the following:
listener

The listener to be added. Must implement one of the following interfaces that match the listener_type parameter:

A null value may be used to remove a listener for the events specified by the listener_type parameter.

Returns
Previous listener of the specified type.

◆ HCallback()

void HCallback ( GlgObject  viewport)

H callback.

This method is invoked after the bean's drawing has been loaded, but before its object hierarchy has been setup.

The method can be used for setting initial parameters of the loaded drawing before its hierarchy has been setup.

Parameters
viewportThe top viewport object of the bean's drawing.

Implements GlgHListener.

◆ HierarchyCallback()

void HierarchyCallback ( GlgObject  top_viewport,
GlgHierarchyData  hierarchy_info 
)

Hierarchy callback.

is used to get access to the drawing to be displayed in the SubWindow and SubDrawing objects before the drawing is displayed.

This method is invoked when a SubWindow object in the bean's drawing loads its template drawing, or when a SubDrawing loads its template. The method is invokes several times at different stages of the template setup and may used to configure the SubWindow and SubDrawing instances before they are displayed.

The method may be overridden by bean's subclasses to implement custom instance setup logic.

A Hierarchy listener can be added using AddListener as an alternative to subclassing.

Parameters
top_viewportThe top-level viewport object.
hierarchy_infoGlgHierarchyData object containing information about the subdrawing that triggered the callback. See GlgHierarchyData for more information.

The method is invoked with the same parameters as the HierarchyCallback method of GlgHierarchyListener. See HierarchyCallback for more information.

Implements GlgHierarchyListener.

◆ InputCallback()

void InputCallback ( GlgObject  vp,
GlgObject  message_obj 
)

Input callback.

This method is invoked to handle user interaction with input objects, as well as to perform object selection and action processing, and may be overridden by bean's subclasses to implement custom interaction logic.

An Input listener can be added using AddListener as an alternative to subclassing.

Parameters
vpThe top-level viewport object.
message_objMessage object containing input event information.

The method is invoked with the same parameters as the InputCallback method of GlgInputListener. See InputCallback for more information.

Implements GlgInputListener.

◆ ReadyCallback()

void ReadyCallback ( GlgObject  viewport)

Ready callback.

This method is invoked when the bean has finished initializing, loading and displaying its drawing. This method may be overridden by bean's subclasses to provide a custom bean initialization logic.

The IsReady method can also be used to query the bean's readiness.

Parameters
viewportThe top viewport object of the loaded drawing.

Implements GlgReadyListener.

◆ SelectCallback()

void SelectCallback ( GlgObject  vp,
Object[]  name_array,
int  button 
)

Select callback.

This method provides a simplified name-based interface to handle object selection. It is invoked when objects are selected with the mouse and may be overridden by bean's subclasses to implement custom selection logic.

A Select listener can be added using AddListener as an alternative to subclassing.

InputCallback provides an alternative callback that provides more elaborate selection information.

Parameters
vpThe top-level viewport object.
name_arrayA null-terminated list of names of all named objects selected with the mouse, or null if no objects were selected.
buttonThe mouse button that was pressed to select objects.

The method is invoked with the same parameters as the SelectCallback method of GlgSelectListener. See SelectCallback for more information.

Implements GlgSelectListener.

◆ Trace2Callback()

void Trace2Callback ( GlgObject  top_viewport,
GlgTraceData  trace_info 
)

This method is invoked to handle any events in the bean's drawing and may be overridden by bean's subclasses to implement custom event handling logic.

The method is similar to the TraceCallback, but is invoked after the event has been processed.

A Trace2 listener can be added using AddListener as an alternative to subclassing.

Parameters
top_viewportThe top-level viewport object.
trace_infoA GlgTraceData object containing detailed event information. See GlgTraceData for more information.

The method is invoked with the same parameters as the TraceCallback method of GlgTraceListener. See TraceCallback for more information.

◆ TraceCallback()

void TraceCallback ( GlgObject  top_viewport,
GlgTraceData  trace_info 
)

Trace callback.

This method is invoked to handle any events in the bean's drawing and may be overridden by bean's subclasses to implement custom event handling logic. The method is invoked before the event has been processed.

A Trace listener can be added using AddListener as an alternative to subclassing.

Parameters
top_viewportThe top-level viewport object.
trace_infoA GlgTraceData object containing detailed event information. See GlgTraceData for more information.

The method is invoked with the same parameters as the TraceCallback method of GlgTraceListener. See TraceCallback for more information.

Implements GlgTraceListener.

◆ VCallback()

void VCallback ( GlgObject  viewport)

V callback.

This method is invoked after the object hierarchy of the bean's drawing has been setup.

The method can be used for setting initial parameters of the loaded drawing after its hierarchy has been setup, but before the drawing is displayed.

Parameters
viewportThe top viewport object of the bean's drawing.

Implements GlgVListener.