<<<<<<<<<<<<<<<<<

motif_text_field(motif) Motif motif_text_field(motif)

NAME

motif_text_field - single line text edit/display class

DESCRIPTION

The motif_text_field class provides functionality nearly identical to that of the motif_text class, however, only a single line of text can be manipulated. It is presumably less abusive of system resources, since full editing capabilities are not needed.

Some functionality was apparently overlooked by the implementors of the TextField widget. As of Motif 1.1.2, there is no focusCallback for the widget, so no focus_action instance variable is currently available in the motif_text_field class. If that functionality is needed, a motif_text object should be used.

The TextField widget is new with Motif 1.1. Under Motif 1.0, a Text widget is used as the underlying widget of the class. This has not bee tested, however.

For a more complete description of this Motif widget, consult "OSF/Motif Programmer's Reference."

SUPERCLASS

motif_primitive

INSTANCE VARIABLES

filename names the file to be used by read! or write!.

x, y are used to convey coordinate information to and from various Text widget functions.

from, to bound the selection. Used to convey selection bounds to and from various Text widget functions.

activate_action, focus_action, losing_focus_action, modify_verify_action, value_changed_action are LYMB callback actions specific to the Text widget. See the XmText man page for details.

MESSAGES

add_mode_on! enables Add Mode. In Add Mode, the insertion cursor can be moved without disturbing the primary selection.

add_mode_off! disables Add Mode. In Add Mode, the insertion cursor can be moved without disturbing the primary selection.

current_line? returns the line number holding the insertion cursor. For compatibility with motif_text class. Always returns 1.

read! reads the contents of the file named by the filename instance variable into the Text widget, replacing its current contents. It is the programmer's responsibility to ensure that the file is readable. No error recovery is performed by this message.

write! writes the contents of the Text widget to the file named by the filename instance variable. It is the programmer's responsibility to ensure that the file is writable. No error recovery is performed by this message.

xy= (x,y) Sets the x and y instance variables simultaneously. Shorthand for x=x xy=y.

clear_selection! clears the primary selection in the Text widget.

copy! copies the primary selection to the clipboard.

cut! copies the primary selection to the clipboard and deletes the selected text.

baseline? returns the x positition of the first baseline.

highlight: mode highlights the text between the from and to instance variables using mode. Mode can be one of XmHIGHLIGHT_NORMAL, XmHIGHLIGHT_SELECTED, or XmHIGHLIGHT_SECONDARY_SELECTED.

insert: (pos, string) inserts string into the Text widget at position pos.

last_position? returns the last character position of the Text widget.

paste! inserts the clipboard position at the insertion cursor.

position_of_xy? returns the character position nearest to the current x and y instance variables.

xy_of_position: pos computes the (x,y) position of character position pos. The x and y instance variables are set.

remove! deletes the primary selection.

replace: string replaces the contents of the Text widget between the from and to instance variables with string.

selection? returns the value of the primary selection.

selection_position? returns the first and last positions of the primary selection.

set_selection! sets the primary selection based upon the curren from and to instance variables.

show_position: pos forces text at position pos to be displayed.

substring? returns the substring between (inclusive) positions specified by the instance variables from and to. Note that the first position is position 0.

string = string_to_display sets the value of the character string to be displayed by the text widget. While the string can also be set by the value resource, using the string= method is the preferred manner to set the string.

string? returns the current value of the character string displayed in the text widget.

@ resource selects resource for a subsequent set or query.

: value sets the current resource to value. Since most resources have mixed case, you should enclose any resource name in quotes. Resource names are the Motif names with the XmN prefix removed. Some resources can only be set before the widget is created. For efficiency, set as many resources as you can before creation.

scalar_value? returns the value of the current resource whose type is integer.

string_value? returns the value of the current resource whose type is string.

pointer_value? returns the value of the current resource whose type is a pointer of any kind.

create! creates an instance of the widget. Any resources that have been specified prior to the create! will be set. An id? message also sends a create!.

on! realizes the widget. Realizing a widget creates its windows and displays it when it is managed.

EXAMPLE

scalar new: false = 0; scalar new: true = 1;

motif application=`Motif_text_field Example' ;

motif_row_column new: rc parent=motif create! ;

actions new: activate_text1 tick_actions=`! (1) activate' ;

actions new: value_changed_text1 tick_actions=`! (1) value changed' ;

actions new: modify_verify_text1 tick_actions=`! (1) modify verify' ;

actions new: losing_focus_text1 tick_actions=`! (1) losing focus' ;

motif_text_field new: text_1 parent=rc @ `columns' : 40

@ `resizeWidth' : false @ `editable' : false @ `value' : `Hello World (cannot edit)' activate_action=`activate_text1' value_changed_action=`value_changed_text1' modify_verify_action=`modify_verify_text1' losing_focus_action=`losing_focus_text1' lose_primary_action=`callback' motion_verify_action=`callback' gain_primary_action=`callback' create! ;

actions new: activate_text2 tick_actions=`! (2) activate' ;

actions new: value_changed_text2 tick_actions=`! (2) value changed' ;

actions new: modify_verify_text2 tick_actions=`! (2) modify verify' ;

actions new: losing_focus_text2 tick_actions=`! (2) losing focus' ;

procedure new: `callback' in_formals=(`widget',`action') call_actions=` widget print:`value'; action print:`value'; ' ;

motif_text_field new: text_2 parent=rc @ `columns' : 40 @ `resizeWidth' : false @ `editable' : true @ `value' : `Hello World (edit this)' activate_action=`activate_text2' value_changed_action=`value_changed_text2' modify_verify_action=`modify_verify_text2' losing_focus_action=`losing_focus_text2' create! ;

actions new: exit tick_actions=`motif exit!' ;

motif_push_button new: pb parent=rc @ `labelString' : `Exit' activate_action=exit create! ;

motif on! start!;

SEE ALSO

motif, motif_primitive, motif_text, XmText(3X)


Please send comments and suggestions to
consult@rpi.edu