Try OpenEdge Now
skip to main content
Introducing the Progress Developer Studio for OpenEdge Visual Designer
Creating the Login Dialog : Adding LeftBar.cls to the project : Subscribing to events and adding handlers
 

Subscribing to events and adding handlers

LeftBar.cls requires event handlers to respond when a group is expanded and when an item is chosen. In this section you add the code for, and subscribe to ultraexplorerbar1_GroupExpanding and ultraexplorerbar1_ActiveItemChanged, which respond to group expansion and item selection.
To add GroupExpanding and ActiveItemChanged to LeftBar.cls:
1. Open LeftBar.cls in the ABL Editor.
If you have LeftBar.cls open in the Visual Designer, press F9 to open it in the ABL Editor.
2. Add the following to the USING statements near the top of the file:
USING openedge.tutorial.ui.*.
USING Infragistics.Win.UltraWinExplorerBar.*.
These statements are necessary so that the class and interface references in the event handlers are valid.
3. Add the following code before the END CLASS statement to implement the event handlers:
@VisualDesigner.
METHOD PRIVATE VOID ultraexplorerbar1_ActiveItemChanged
  (INPUT sender AS System.Object,
  INPUT e AS Infragistics.Win.UltraWinExplorerBar.ItemEventArgs):
   IF e:Item:Group:Index = 0 THEN
   CAST(THIS-OBJECT:ParentForm, IUser):SetUser( e:Item:Key, e:Item:Key).
   ELSE DO:
     DEF VAR styleFile AS System.IO.FileInfo.
     styleFile = NEW System.IO.FileInfo( e:Item:Key ).
     CAST(THIS-OBJECT:ParentForm, IStyling):SetStyle( styleFile ).
   END.
END METHOD.

@VisualDesigner.
METHOD PRIVATE VOID ultraExplorerBar1_GroupExpanding
  (INPUT sender AS System.Object, INPUT e AS   Infragistics.Win.UltraWinExplorerBar.CancelableGroupEventArgs ):
   
DEFINE VARIABLE iLoop as integer no-undo.
   DEFINE VARIABLE grp as UltraExplorerBarGroup no-undo.

   DO iLoop = 0 to ultraExplorerBar1:Groups:Count - 1:
     grp = cast(ultraExplorerBar1:Groups:GetItem(iLoop),      UltraExplorerBarGroup).
     /* Must use the Equals() method for objects */
     IF NOT grp:Equals(e:Group) THEN grp:Expanded = False.
   END.
   RETURN.
END METHOD.
4. In the Visual Designer, select ultraExplorerBar1.
5. Open the Events tab in the Properties view.
6. Set the ActiveItemChanged event to ultraExplorerBar1_ActiveItemChanged.
A list of the event handlers that you can subscribe to appears in a drop-down menu, as shown in the following illustration:
7. Set GroupExpanding event to ultraExplorerBar1_GroupExpanding.
8. Save and close LeftBar.cls.