Home‎ > ‎

Mouse Messages and Functions

Adv. Mouse Messages and Functions (code - mouseMove.livecode) (file is at bottom)

If you click on the Dictionary icon in the top Edit bar, you will open up the LiveCode Dictionary.
Open it up and type "mouse" in the search field. You will see the items with the word "mouse" in them. For the most part, there are messages and functions.

Messages are the standard messages for which you can write handlers for. Functions are commands that usually return something to you when you call them.

Here is what you should see: I highlighted the mouseUp message and you can see it's summary and examples in the bottom pane. You should know this already


The messages are ones that you can write code for. They include: mouseLeave, mouseMove, mouseStillDown, mouseUp and many more.
The functions return information to you: mouseLoc, mouseLine, mouseText, mouseH and mouseV and many more

To see how these work, let us open a new card and try some of them out. 
Add 3 "Text Entry" fields and call them "x", "y" and "z" (I do not like to do a lot of typing)
Add a label field and put some words in it's content
Add a bunch of buttons and set them to different colors.

Finally, add the following code to the card script:

            on mouseMove

                   put the mouseLoc into field "x"

                   put the mouseText into field "y"

                   put the mouseColor into field "z"

            end mouseMove


With a few label fields, it should look like this:


                 


As you move your mouse around, the code gets the "mouseMove" message and calls each of the functions: mouseLoc, mouseText and mouseColor and puts the information that they return into our fields on the card.


From the Dictionary, the mouseLoc returns the location of the mouse as it moves (in the coordinates x,y). The mouseText returns any 'text' that is under the cursor at that time. The mouseColor returns the RGB colors of any pixels under the mouse pointer. 


With a little imagination, you can think of many new, unique and fun things to do with these messages and functions. You can also write many useful Apps and programs using them too.


Messages

Many, many messages are sent out constantly on the computer. Everything you do down to the smallest detail is advertised as well as any other thing that happens in the computer.


If you are really curious, you can see all those messages and experiment. Do not worry, you can not hurt anything by looking at them.


To see the messages, you do the following:


1. Click on "Development", the click on "Message Watcher"


                     


      A window will open with messages rushing by. We can reduce them by checking on the button "Suppress..." at the bottom of the window


                  

    Check the messages that you want to suppress (that you do not want to see) and add the mouseMove message in the box


            


    Now it is easier to read because we just see the basic mouse messages. Move your mouse around and watch the messages go by.


             


Play around with the different messages and uncheck other boxes in the "Suppress..." window. Experiment, have fun. Type on the keyboard, see what the messages are given off. You may find some of them useful.

Try it with some of the other LiveCode programs that you have written. See the messages and watch your own message handlers work (the ones that you wrote)


ċ
mouseMove.livecode
(3k)
cyril.pruszko@pgcps.org,
Mar 19, 2014, 6:36 PM
Comments