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: | |
1, if this event happened | ||
0, if this event didn't happen | ||
ret_event can include following elements: | ||
ret_event.key | the string of the key if a key has been pressed | |
ret_event.keysym | the integer code of the key if a key has been pressed (the mapping of keys to integer codes may vary with the operating system) | |
ret_event.button | one of the integers 1,2,3, returning which mouse button has been pressed | |
ret_event.xy | (only if called with 4 arguments) | |
a (1x2) vector of integers, returning the window coordinates of the mouse pointer if a mouse button has been pressed (e.g. 0~0 is the upper left corner of the window) | ||
ret_event.xyreal | (only if called with 4 arguments and the plotted data has 2 dimensions) | |
a (1x2) integer vector returning the real coordinates of the mouse pointer in the data space. |
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.
Group: | Statistical Data Analysis |
Topic: | Graphical User Interfac |
See also: | setmode |