Class XbpMLE() Foundation

Class function of the XbpMLE class.

Superclass
Description

The XbpMLE class provides objects that manage multi-line text entry fields. These are dialog elements that display text within rectangular screen areas. The "text" displayed in each entry field is a character string that may be formatted using the characters Carriage Return+Line Feed (CRLF) to include many text lines. This character string is stored in the edit buffer of the XbpMLE object. Both horizontal and vertical scroll bars are displayed to allow easy navigation through long text. The text can be edited when the XbpMLE object is in edit mode (the default setting). The current cursor position marks the point where characters input using the keyboard are inserted or overwrite existing characters.

By default, XbpMLE objects use automatic word wrap when displaying text. This means that the length of text lines is limited during display to the width of the edit window. Automatic word wrap can be turned off to allow each row of text displayed in the edit window to include the entire row delimited by the characters CRLF.

XbpMLE objects allow sections of text to be selected (marked) and copied to the clipboard. Characters from the clipboard can also be inserted into the text buffer of the XbpMLE object. The XbpMLE object processes keyboard entries as a series of independent character inputs. The keys that are used to input ASCII characters are copied into the edit buffer while 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 XbpMLE object along with the default action each key causes:

Keys for editing an XbpMLE object
Key Description
Left Arrow Move cursor one character to the left
Shift+Left Arrow Select one character to the left
Shift+Ctrl+Left Arrow Select one word to the left
Right Arrow Move one character to the right
Shift+Right Arrow Select one character to the right
Shift+Ctrl+Right Arrow Select one word to the right
Up Arrow Move up one row
Shift+Up Arrow Select one row up
Down Arrow Move down one row
Shift+Down Arrow Select one row down
Page Up Move one page up
Ctrl+Page Up Move one page to the left
Page Down Move one page down
Ctrl+Page Down Move one page to the right
Home Move to beginning of current row
Shift+Home Select all characters to start of current row
Ctrl+Home Move to start of edit buffer
Shift+Ctrl+Home Select all characters to start of edit buffer
End Move to end of current row
Shift+End Select all characters to end of current row
Ctrl+End Move to end of edit buffer
Shift+Ctrl+End Select all characters to end of edit buffer
Backspace Delete the character to the left of cursor
Insert *) Toggle between "Insert" and "Overstrike" edit modes
Shift+Insert Delete selected characters and replace with characters from 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
Return New row
Esc Ignored
Tab Copied into the edit buffer as character if :ignoreTab is set to .F.
Others Other keys containing ASCII characters are copied to the edit buffer as characters
  1. Windows does not support overstrike mode

The xbeP_Keyboard event is generally generated for each keypress. This allows the default behavior of the XbpMLE object to be redefined in the :keyBoard() callback method or the callback code block.

Class methods
:new()
Creates an instance of the XbpMLE 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.

:border
Displays the edit window with a border.
:editable
Determines whether the text contained in the edit buffer of the XbpMLE object can be modified.
:horizScroll
Determines whether the horizontal scroll bar is displayed.
:ignoreTab
Tab key not interpreted as a character.
:undo
Determines whether changes in the edit buffer can be undone.
:vertScroll
Determines whether a vertical scroll bar is displayed.
:wordWrap
Displays text using automatic word wrap.
Runtime data
:changed
Determines whether the text in the edit buffer has been changed by user entry.
Life cycle
:create()
Requests system resources for the XbpMLE object.
:configure()
Reconfigures the XbpMLE object after :create() has been executed.
:destroy()
Releases the system resources of the XbpMLE object.
Manipulation
:charFromLine()
Determines the position of the first character in the specified row within the edit buffer.
:clear()
Deletes all of the characters in the edit buffer.
:copyMarked()
Copies the selected characters from the XbpMLE object to the clipboard.
:cutMarked()
Deletes the selected characters from the edit buffer and copies them to the clipboard.
:delete()
Deletes characters at a specific position in the edit buffer.
:deleteMarked()
Deletes the selected characters from the edit buffer.
:getData()
Returns the character string in the edit buffer of the XbpMLE object.
:hideBalloonTip()
Hides the balloon tip window.
:insert()
Inserts a character string into the edit buffer.
:lineFromChar()
Calculates the row number based on the character position in the edit buffer.
:pasteMarked()
Replaces the selected characters in the edit buffer with characters from the clipboard.
:pos()
Determines the current position of the cursor in the edit buffer.
:queryFirstChar()
Returns the position of the first character visible in the XbpMLE 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.
:undo()
Undo changes in the edit buffer.
Settings
:setEditable()
Sets whether the edit buffer of the XbpMLE object is READONLY.
:setWrap()
Turn on or off automatic word wrap in the edit window.
Events
:hScroll
The character string in the XbpMLE object has been horizontally scrolled.
:vScroll
The character string in the XbpMLE object has been vertically scrolled.
Examples
Simple text editor - XbpMLE()

// This example demonstrates how an XbpMLE object is created 
// and assigned a data code block. The XbpMLE used in the 
// example is a very simple text editor. A file is read, 
// the text is copied into the edit buffer using :setData(), 
// copied back to the variable using :getData(), and then 
// written back into the file. The method :setData() and 
// :getData() execute the data code block contained in 
// :dataLink. This code assigns the text to a LOCAL variable. 


#include "Appevent.ch" 

PROCEDURE Main( cFileName ) 
   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL cText, oMLE 

   SetColor("N/W") 
   CLS 

   IF Empty(cFileName) .OR. ! File(cFileName) 
      ? Chr(7) 
      WAIT "File name must be specified" 
      QUIT 
   ENDIF 

   // Read file into LOCAL variable 
   cText := MemoRead( cFileName ) 

   // Create MLE, specify position using :create() and 
   // assign data code block accessing LOCAL variable 
   oMLE          := XbpMLE():new() 
   oMLE:wordWrap :=.F. 
   oMLE:dataLink := {|x| IIf( x==NIL, cText, cText := x ) } 
   oMLE:create( , , {50,50}, {550,300} ) 

   // Copy text from LOCAL variable into edit buffer 
   // via :dataLink 
   oMLE:setData() 

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

   // Get text from edit buffer and assign to LOCAL variable 
   // via :dataLink 
   oMLE:getData() 

   // Write text from the LOCAL variables back to the file 
   IF oMLE:changed 
      MemoWrit( cFileName, cText ) 
   ENDIF 
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.