Group: | Statistical Data Analysis |
Topic: | Graphical User Interfac |
See also: | setmode |
Function: | readevent | |
Description: | readevent reads a key- or a mouse- event while a program is running. An "event" is a stroke of a key or a click of a mouse button. readevent will be mainly useful for letting XploRe know whether such an event has occured and to get some special information like the coordinates where the mouse click happened or a key code. readevent will "record" the relevant event if it ocurred previous to the moment when readevent is called. readevent can therefore be used to "tell" the program that the event has happened. Sometimes it is usefull to call at first setmode(...., 2) to disable default event handling. |
Usage: | ret_event=readevent(which_event{, di, row_num, col_num}) | |
Input: | ||
which_event | 0 for key; 1 for mouse | |
di | display | |
row_num | integer | |
col_num | integer | |
Output: | ||
ret_event | a complex object: |
d=createdisplay(1, 1) x=(1:500)*6.28/50 u=sin(x)~sin(3*x)~(sin(2*x)/100)~sin(5*x)~(sin(7*x)/100) setmaskl(u,(1:rows(u))', 1, 1, 1) show(d, 1, 1, u) proc(m) = em(dim) i=0 m=matrix(dim, dim) m=m-m while(i<dim) i=i+1 m[i+1, i+1]=1 endo endp proc() = rotate(d, x, y) keypressed=readevent(0) while(keypressed==0) go=getgopt(d, x, y) dim=cols(go.rotcos) angle=uniform(dim, 1)/5 i=1 m=em(dim) while(i<dim) i=i+1 mm=em(dim) mm[1, 1]=cos(angle[i]) mm[i, i]=cos(angle[i]) mm[1, i]=-sin(angle[i]) mm[i, 1]=sin(angle[i]) m=m*mm endo gort=go.rotcos gort=gort*m setgopt(d, x, y, "rotcos", gort) keypressed=readevent(0) endo endp rotate(d, 1, 1)
a line that you see is rotated until you press some key.