background image
<< Class Hierarchy - Logical classes | Class Hierarchy - Redefining a method >>
Class Hierarchy - Adding methods to a class
<< Class Hierarchy - Logical classes | Class Hierarchy - Redefining a method >>
306
User's Guide
16 E
XTENDING
THE
C
LASS
H
IERARCHY
Adding methods to a class
·
AgentClass, which defines the methods you can use to set options in the
4Test Agent. (The 4Test Agent is the component of SilkTest that
translates the method calls in your testcases into the appropriate GUI-
specific event streams.)
The predefined identifiers for the Cursor, Clipboard, and Agent You do
not record declarations for the cursor, the clipboard, or the Agent. Instead,
you use predefined identifiers for each of these objects when you want to use
a method to act against the object:
·
The predefined identifier for the 4Test Agent is Agent
·
The predefined identifier for the clipboard is Clipboard
·
The predefined identifier for the mouse pointer is Cursor
For example, to set a 4Test Agent option, you use a call such as the following:
Agent.SetOption (OPT_VERIFY_COORD, TRUE)
DesktopWin
Because the desktop is a GUI object, it derives from the AnyWin class.
However, unlike other GUI objects, you do not have to record a declaration
for the desktop. Instead, you use the predefined identifier Desktop when you
want to use a method on the desktop.
For example, to call the GetActive method on the desktop, you use a call like
the following:
wActive = Desktop.GetActive ()
Adding methods to a class
Defining a new
method
To add a method to an existing class, you use the following syntax to begin
the method definition:
winclass ExistingClass : ExistingClass
The syntax ExistingClass : ExistingClass means that the declaration that
follows extends the existing class definition, instead of replacing it. For more
information, see "winclass declaration" in online Help.
Example 1
This example adds to the TextField class a method that selects all of the text
in the text field.
winclass TextField : TextField
SelectAll ()
STRING sKey1, sKey2
switch (GetGUIType ())