background image
<< Custom Objects - Supporting nongraphical controls | Custom Objects - Using Clipboard methods >>
Custom Objects - Supporting custom text fields
<< Custom Objects - Supporting nongraphical controls | Custom Objects - Using Clipboard methods >>
User's Guide
323
17 S
UPPORTING
C
USTOM
O
BJECTS
Supporting nongraphical controls
·
Otherwise, you can add partial support for the custom object by creating
a new class derived from AnyWin and writing methods that use the
primitive methods of the AnyWin class, like TypeKeys and MoveMouse,
to implement, as much as is possible, the methods appropriate for the
non-graphical control.
Supporting custom
text fields
Suppose your application has an object that acts like a text field, but which is
not implemented using your GUI's standard text field object. The following
example illustrates how you can derive a new class from AnyWin and define
methods for the custom object. The example defines the ClearText,
GetMultiText, SetMultiText, and GetMultiSelText methods.
// This new class defines methods that re-implement
// the methods of the TextField class so that they will
// work on custom text fields. To be able to use these
// methods, you must change the class of object in the
// declarations from CustomWin to CustomTextField.
winclass CustomTextField : AnyWin
// This method clears the text field by moving the
// cursor to the start of field, selecting the text
// to the end of the file, and deleting the selected
// text
void ClearText ()
TypeKeys ("<Ctrl-Home>")
TypeKeys ("<Ctrl-Shift-End>")
TypeKeys ("<Backspace>")
// This method writes text to the text field.
// It first calls ClearText and then uses TypeKeys to
// input the text passed in.
void SetMultiText (STRING sText)
ClearText ()
TypeKeys (sText)
// This copies the currently selected text to the
// clipboard and returns the clipboard contents.
LIST OF STRING GetMultiSelText ()
Clipboard.SetText () // Clear the clipboard
TypeKeys ("<Ctrl-Insert>")
return (Clipboard.GetText ())
// This method highlights all of the text in the
// text field, copies the highlighted text to the
// clipboard, and returns the clipboard contents.