Lingo Dictionary > L-N > mouseChar |  |

mouseChar

Syntax

    the mouseChar

Description

System property; used for field sprites, contains the number of the character that is under the cursor when the property is called. The count is from the beginning of the field. If the mouse is not over a field or is in the gutter of a field, the result is -1.

The value of the `mouseChar` property can change in a handler or repeat loop. If a handler or repeat loop uses this property multiple times, it's usually a good idea to call the property once and assign its value to a local variable.

Example

This statement determines whether the cursor is over a field sprite and changes the content of the field cast member Instructions to "Please point to a character." when it is:

    if the mouseChar = -1 then
    	member("Instructions").text = "Please point to a character."

Example

This statement assigns the character under the cursor in the specified field to the variable `currentChar`:

    currentChar = member(the mouseMember).char[the mouseChar]

Example

This handler highlights the character under the cursor when the sprite contains a text cast member:

    property spriteNum

    on mouseWithin me
    	if sprite(spriteNum).member.type = #field then
    		MC = the mousechar
    		if MC < 1 then exit    -- if over a border, final line, etc
    		hilite char MC of field sprite(spriteNum).member
    		else alert "Sorry, 'hilite' and 'mouseChar' are for fields."
    end

See also

`mouseItem`, `mouseLine`, `mouseWord`, `char...of`, `number (characters)`