Class XbpSLE() Foundation

Class function of the XbpSLE class.

Superclass
Description

The XbpSLE class provides objects that manage individual text entry fields (single-line edit fields). These are rectangular screen areas for keyboard input that allow character strings stored in the edit buffer of the XbpSLE object to be created or edited. The cursor marks the location within the character string where characters are inserted or overwritten.

An XbpSLE object can edit only character strings. It includes an edit buffer that is limited to 32 characters by default. When the character string being edited might contain more than 32 characters, the edit buffer must be dimensioned using the :bufferLength instance variable. The buffer can have a maximum size of 64kB characters (this limit is imposed by OS/2).

The XbpSLE object independently processes keyboard entries. The keys that are used to input ASCII characters are copied into the edit buffer while some other specific keys are automatically processed (such as the Insert and Delete keys). The following table lists the keys that receive special processing by the XbpSLE object along with action caused by each key:

Keys for editing an XbpSLE object
Key Description
Left Arrow Move cursor one character to the left
Right Arrow Move cursor one character to the right
Shift+Left Arrow Select one character to the left
Shift+Right Arrow Select one character to the right
Up Arrow Ignored
Down Arrow Ignored
Home Go to the start of the edit buffer
End Go to the end of the edit buffer
Backspace Delete the character to the left of the cursor
Shift+Insert Delete selected characters and replace them with the characters stored in the clipboard
Ctrl+Insert Copy marked characters to the clipboard
Delete Delete the character to the right of cursor or delete selected characters without copying them to the clipboard
Shift+Delete Delete selected characters and copy them to the clipboard
Ctrl+Delete Delete characters marked in the edit buffer without copying them to the clipboard
Return Ignored
Esc Ignored
Page Up Ignored
Page Down Ignored
Shift+Tab Transfer input focus to the previous Xbase Part
Tab Transfer the input focus to the next Xbase Part
Others Other keys containing ASCII characters are copied to the edit buffer as characters

An XbpSLE object can only edit character strings. Blank spaces at the end of character strings are not automatically deleted but are treated like any other character. If the edit buffer of an XbpSLE object is filled with blank spaces (Chr(32)), no additional characters can be added. In this case, characters must be deleted from the edit buffer before new characters can be added.

Class methods
:new()
Creates an instance of the XbpSLE class.
Configuration

The instance variables in this group configure system resources. If changes are made to these values, they must either be made before the :create() method is executed or the :configure() method must be used to activate the changes.

:align
Determines the alignment of text within the XbpSLE object.
:autoKeyboard
(De)Activates automatic processing of keyboard events.
:autoSize
Automatically fits the size of the entry field to the edit buffer.
:autoTab
Automatically generates a Tab message when the edit buffer is full.
:border
Displays the entry field with a border.
:bufferLength
Sets the maximum length of the edit buffer.
:editable
Determines whether the text contained in the edit buffer of the XbpSLE object can be modified.
:unReadable
Determines whether the characters in the entry field are displayed as asterisks ("*").
Runtime data
:changed
Indicates whether the edit buffer has been changed by user entry.
:cueBanner
Specifies the cue banner text displayed by the entry field.
Life cycle
:create()
Requests system resources for the XbpSLE object.
:configure()
Reconfigures the XbpSLE object after :create() has been executed.
:destroy()
Releases the system resources of the XbpSLE object.
Manipulation
:clear()
Deletes all of the characters in the edit buffer.
:copyMarked()
Copies the selected characters from the XbpSLE object to the clipboard.
:cutMarked()
Deletes the selected characters from the edit buffer and copies them to the clipboard.
:deleteMarked()
Deletes the selected characters from the edit buffer.
:editBuffer()
Returns the value in the edit buffer of the XbpSLE object.
:getData()
Returns the character string in the edit buffer of the XbpSLE object.
:hideBalloonTip()
Hides the balloon tip window.
:pasteMarked()
Replaces the selected characters in the edit buffer with characters from the clipboard.
:queryFirstChar()
Returns the position of the first character visible on the left of the XbpSLE screen display.
:queryMarked()
Determines the position of the first and last characters selected.
:setData()
Sets the value of the character string in the edit buffer.
:setFirstChar()
Sets the first character visible in the edit window.
:setMarked()
Sets the characters selected in the edit buffer.
:showBalloonTip()
Displays a balloon-like window with information on the entry field.
Settings
:setEditable()
Sets whether the edit buffer of the XbpSLE object is READONLY.
:setInsertMode()
Sets or returns the insert mode (insert or overstrike).
Events
:hScroll
The character string in the XbpSLE object has been horizontally scrolled.
:typeOut
The edit buffer is full.
Examples
Single line entry fields using XbpSLE()

// In the example, two XbpSLE objects are created in an XbpCrt 
// window with edit buffers limited to 20 and 15 characters, 
// respectively. Both XbpSLE objects use data code blocks 
// to access LOCAL variables. These code blocks are evaluated 
// when the XbpSLE object loses the input focus. In the callback 
// slot :killInputFocus, :getData() is called to read the edit 
// buffer and assign the values to LOCAL variables via :dataLink. 

#include "Appevent.ch" 

PROCEDURE Main 
   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL cVarA := "Test A", cVarB := "Test B" 
   SetColor("N/W") 
   CLS 

   // Create first SLE, specify position using :create() 
   // On :typeOut set the focus to the second SLE 
   oXbp              := XbpSLE():new() 
   oXbp:autoTab      := .T. 
   oXbp:bufferLength := 20 

   // Data code block containing assignment to LOCAL variable 
   oXbp:dataLink := {|x| IIf( x==NIL, cVarA, cVarA := x ) } 

   oXbp:create( , , {100,200}, {100,30} ) 

   oXbp:setData() 

   // Assign the value of the edit buffer to a LOCAL variable 
   // when the input focus is lost 
   oXbp:killInputFocus := ; 
       { |x,y,oSLE| oSLE:getData(), QOut( "cVarA =", cVarA ) } 

   // Create second SLE, specify position using :new() 
   oXbp              := XbpSLE():new( , , {100,150}, {100,30} ) 
   oXbp:tabStop      := .T. 
   oXbp:bufferLength := 15 
   oXbp:dataLink := {|x| IIf( x==NIL, cVarB, cVarB := x ) } 
   oXbp:create() 

   oXbp:setData() 
   oXbp:killInputFocus := ; 
       { |x,y,oSLE| oSLE:getData(), QOut( "cVarB =", cVarB ) } 

   // Event loop 
   nEvent := 0 
   DO WHILE nEvent <> xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:handleEvent( nEvent, mp1, mp2 ) 
   ENDDO 
RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.