Lingo Dictionary > L-N > mouseItem |  |

mouseItem

Syntax

    the mouseItem

Description

System property; contains the number of the item under the pointer when the function is called and the cursor is over a field sprite. (An item is any sequence of characters delimited by the current delimiter as set by `the itemDelimiter` property.) Counting starts at the beginning of the field. If the mouse is not over a field, the result is -1.

The value of the `mouseItem` property can change in a handler or repeat loop. If a handler or repeat loop relies on the initial value of `mouseItem` when the handler or repeat loop begins, 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 an item." when it is not:

    if the mouseItem = -1 then
    	member("Instructions") = "Please point to an item."
    end if

Example

This statement assigns the item under the cursor in the specified field to the variable `currentItem`:

    currentItem = member(mouseMember).item(mouseItem)

Example

This handler highlights the item under the cursor when the mouse button is pressed:

    on mouseDown
    	thisField = sprite(the clickOn).member
    	if the mouseItem < 1 then exit
    	lastItem = 0
    	repeat while the stillDown
    		MI = the mouseItem
    		if MI < 1 then next repeat
    		if MI <> lastItem then
    			thisField.item[MI].hilite()
    			lastItem = MI
    		end if
    	end repeat
    end

See also

`item...of`, `mouseChar`, `mouseLine`, `mouseWord`, `number (items)`, `itemDelimiter`