Livecode Wiki
(Created page with "Sent to a field when the focus is being removed from that field and the field's '''content has changed'''. Syntax: on closeField ... end closeField Examples: on clos...")
Tag: sourceedit
 
(Adding categories)
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
Sent to a field when the focus is being removed from that field and the field's '''content has changed'''.
+
Sent to a [[field]] when the [[focus]] is being removed from that field and the field's content '''has changed'''.
   
 
Syntax:
 
closeField
   
 
Examples:
Syntax:
 
on closeField
 
...
 
end closeField
 
Examples:
 
 
on closeField -- make sure the user has entered a valid date
 
on closeField -- make sure the user has entered a valid date
 
if the text of me is not a date then
 
if the text of me is not a date then
Line 15: Line 13:
 
end closeField
 
end closeField
   
Handle the '''closeField''' message if you want to make sure a field's content is correct after it has been changed.
+
Handle the [[closeField]] message if you want to make sure a
  +
field's content is correct after it has been changed.
   
  +
The selection is removed from a field (and the field loses focus) when
The selection is removed from a field (and the field loses focus) when another window is brought to the front, when the user clicks in another field, or when the user tabs out of the field. The field also loses focus when the select command is used to select text in another field. However, the '''closeField''' message is not sent when the user clicks in the same field.
 
  +
another window is brought to the front, when the user clicks in another
  +
field, or when the user tabs out of the field. The field also loses
  +
focus when the [[select]] command is used to select text in another
  +
[[field]]. However, the [[closeField]] message is not sent when the user
  +
clicks in the same [[field]].
   
The '''closeField''' message is not sent when a handler changes the field's contents using the [[put]] command.
+
The [[closeField]] message is not sent when a [[handler]] changes the
  +
field's contents using the [[put]] command.
   
If the [[lookAndFeel]] property is set to "Macintosh", the '''closeField''' message is generally not sent when another control (such as a button) is clicked. This is because clicked buttons do not receive the focus on Mac OS systems, and therefore the selection remains active.
+
If the [[lookAndFeel]] property is set to "Macintosh", the [[closeField]]
  +
message is generally not sent when another control (such as a
  +
[[button]]) is clicked. This is because clicked buttons do not
  +
receive the [[focus]] on Mac OS systems, and therefore the
  +
[[selection]] remains active.
   
The '''closeField''' message is also sent to buttons whose [[menuMode]] is "comboBox", since the type-in box in a combo box behaves like a field.
+
The [[closeField]] message is also sent to buttons
  +
whose [[menuMode]] is "comboBox", since the type-in box in a combo box
  +
behaves like a [[field]].
   
If a field is closing and its contents have not changed, the [[exitField]] message is sent instead of '''closeField'''.
+
If a field is closing and its contents have not changed, the [[exitField]]
  +
message is sent instead of [[closeField]].
   
See Also: [[focusOut]] Message, [[openField]] Message, [[exitField]] Message
+
See also: [[openField]] (message), [[exitField]] (message), [[focusOut]] (message), [[field]] (object), [[button]] (object), [[menuMode]] (property)
[[Category:Messages]]
+
[[Category: ui]]
  +
[[Category:Text processing]]
  +
[[Category:Fields]]

Latest revision as of 22:29, 27 June 2020

Sent to a field when the focus is being removed from that field and the field's content has changed.

Syntax:

closeField

Examples:

on closeField -- make sure the user has entered a valid date
  if the text of me is not a date then
    beep
    answer "Please enter a date."
    select text of me
  end if
end closeField

Handle the closeField message if you want to make sure a field's content is correct after it has been changed.

The selection is removed from a field (and the field loses focus) when another window is brought to the front, when the user clicks in another field, or when the user tabs out of the field. The field also loses focus when the select command is used to select text in another field. However, the closeField message is not sent when the user clicks in the same field.

The closeField message is not sent when a handler changes the field's contents using the put command.

If the lookAndFeel property is set to "Macintosh", the closeField message is generally not sent when another control (such as a button) is clicked. This is because clicked buttons do not receive the focus on Mac OS systems, and therefore the selection remains active.

The closeField message is also sent to buttons whose menuMode is "comboBox", since the type-in box in a combo box behaves like a field.

If a field is closing and its contents have not changed, the exitField message is sent instead of closeField.

See also: openField (message), exitField (message), focusOut (message), field (object), button (object), menuMode (property)