To define a new method to use on a single GUI object, not for an entire class of objects, you add the method definition to the window declaration for the individual object, not to the class. The syntax is exactly the same as when you define a method for a class.
window MainWin UntitledNotepad ... TextField TextField locator "//TextField"
window MainWin UntitledNotepad ... TextField TextField locator "//TextField" SelectAll() TypeKeys("<Ctrl+a>")
For example, suppose you want to create a method named SetLineNum for a dialog box named GotoLine, which performs the following actions:
The following 4Test code shows how to add the definition for the SetLineNum method to the declaration of the GotoLine dialog box.
window DialogBox GotoLine tag "Goto Line" parent TextEditor const wInvoke = TextEditor.Search.GotoLine void SetLineNum (STRING sLine) Invoke () // open dialog Line.SetText (sLine) // populate text field // whose identifier is Line Accept () // close dialog, accept values //Then, to go to line 7 in the dialog, you use this method call in your testcases: GotoLine.SetLineNum (7)