Mouse position: Difference between revisions

Content added Content deleted
(add common lisp)
Line 267: Line 267:
return 0;
return 0;
}</lang>
}</lang>

=={{header|Common Lisp}}==

With the ltk library.

<lang lisp>
(ql:quickload "ltk")
(in-package :ltk-user)
(defun motion (event)
(format t "~a x position is ~a~&" event (event-x event)))

(with-ltk ()
;; create a small window. Enter the mouse to see lots of events.
(bind *tk* "<Motion>" #'motion))
</lang>
This prints a lot of events of the form


#S(EVENT
:X 0
:Y 85
:KEYCODE ??
:CHAR ??
:WIDTH ??
:HEIGHT ??
:ROOT-X 700
:ROOT-Y 433
:MOUSE-BUTTON ??)

The <code>#S</code> indicates we get a structure, so we can access the x position with <code>(event-x event)</code>.

=={{header|c_sharp|C#}}==
=={{header|c_sharp|C#}}==
Writes the absolute Mouse Position of the Screen into the Console
Writes the absolute Mouse Position of the Screen into the Console