Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FUNCky - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  The m_inbutton() and m_release() functions will halt program
  execution until the user clicks a mouse button, or presses a key.
  Both of these functions act like a mouse version of inkey(0). The
  return value is the inkey() key value of the key the user
  pressed. If they clicked on a mouse button, these functions
  return a 0 for a 'no key' return. These 2 functions are also
  'wait states' as defined by Clipper. A wait state enables you to
  have SET KEY TO procedures active while waiting for input.

  The second consideration is due to the nature of the mouse. Since
  the user usually points at the item they want to select, you will
  have to keep track of the screen locations of the presented
  items. If a 'no key' value is returned to you, then you know you
  will have to figure out what option the user wants to execute by
  figuring out the location of the mouse cursor. If the mouse
  cursor was over the option 'EDIT' on the screen, then you know to
  execute the EDIT module of your program.

  Another method of receiving mouse input is polling. Polling is
  the equivalent of putting inkey() inside a DO WHILE .T. loop.
  FUNCky provides a polling function called isbutton(). A simple
  demonstration would be:

       do while .T.
            if (isbutton(0))
                 do MOUSECLICK
            endif
       enddo

  The isbutton(0) function will return .T. if the left mouse button
  is depressed, and .F. otherwise. To make life easier, the
  isbutton() function is tied into the Clipper keyboard input
  routine so that you can check lastkey() values as well. If the
  user opts to press a key instead of clicking a mouse button, you
  can catch that with lastkey() just as if you were using inkey().
  An example of polling both the keyboard and the mouse would be:

       do while .T.
            if (isbutton(0))
                 do MOUSECLICK
            endif

            if (lastkey() <> 0)
                 do KEYPRESS
            endif
       enddo

  Since FUNCky ties the mouse input routines into the keyboard
  routines, you can poll both the keyboard and the mouse at the
  same time using only the mouse functions. This makes coding
  Clipper for the mouse and keyboard much easier. The isbutton()
  function is also a 'wait state' as defined by Clipper so that
  your SET KEY TO procedures will be executed if the user presses
  the appropriate key.

  One more polling function is available called _isbutton(). The
  underscore equivalent to isbutton() has one minor difference. It
  does not check for keypresses, and it does not update the
  lastkey() value. Executing multiple sequential calls to
  isbutton() clears and resets the lastkey() value every time you
  call it. That makes checking for keyboard input almost impossible
  since the isbutton() function is always clearing the lastkey()
  value to 0. If you need to do multiple calls to the isbutton()
  function, it is best to make one call to isbutton(), and then any
  subsequent calls to _isbutton(). that will insure that the
  lastkey() value will not get cleared too frequently thereby
  increasing your chances of catching a keypress through lastkey()

  Another very important thing to know is the mouse functions are
  transparent. That is to mean that if no mouse is present in the
  system, they will always return the negative, null, or zero
  value. The significance of this is important since it lets you
  use the mouse functions even if there is no mouse present. A call
  to the function m_inbutton() will wait for a keystroke if no
  mouse is present. A call to isbutton() will return .F. if no
  mouse is present, but it will update the lastkey() value if the
  user presses a key. Due to the complete transparency of all the
  mouse functions, it is extremely easy to write programs that do
  not depend on the fact that a mouse is present. You can also
  control the presence of the mouse through the mouse() function.
  Specifying mouse(.T.) will tell all the mouse functions to look
  for a mouse. Specifying mouse(.F.) tells all the mouse functions
  that there is no mouse. That way you can turn mouse support on
  and off at will.

  Polling is by far the preferred method to check for mouse input
  since it lets you update the screen as the mouse cursor is moved.
  If the user passes the mouse cursor over the word 'Edit' in a
  menu, then that word can be displayed in reverse video to signify
  that it is the active option if the user were to press a button.

See Also: isbutton() _isbutton() m_release() m_inbutton()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson