Hello,
I'm running a snippet of code I found from a 1995 post. wselect allows
you to click on a plot window to change the focus to that window.
It works fine if you just use it once, but if you're going thru a
loop, as in trash2.pro below, wselect thinks the focus is on the last
window you selected and you can't select another one. If you put in
the lines of code below:
go=' '
read,'.......................',go
that returns the focus to the x-window, and wselect works fine. You
can change the focus to a new window, digitize a few points, then
choose another window, digitize, wash, rinse, repeat.
Is there some way to return the focus to the command line window
without having to type something in from the keyboard? This is a
basically a rehash of a topic from 2005 where the problem never was
resolved....
Thanks,
Mark
pro wselect
;+
; ROUTINE: wselect
;
; PURPOSE: wset to window selected by a mouse click
;
; USEAGE: wselect
;
; INPUT: none
;
; OUTPUT: none
;
; SIDE EFFECTS:
; changes current window (changes value of !d.window)
;
; author: Paul Ricchiazzi 11jan94
; Institute for Computational Earth System Science
; University of California, Santa Barbara
;-
;
device,window_state=ws
nw=n_elements(ws)
;*********************************************************** ****
; lines below have to be inserted to remove focus from last plot
window digitized
; this is done by putting the focus on X11 window
; if one uses wselect only once, ie, before a plot window has been
selected, lines below are not needed.
; however, they *are* needed for multiple calls to wselect
go=''
;read,'.............',go
; focus is now on X11, and plot window selection will run OK
chosen=-1
repeat begin
for i=0,nw-1 do begin
if ws(i) eq 1 then begin
wset,i
cursor,xdum,ydum,/data,/nowait
if !err ne 0 then chosen=i
endif
endfor
endrep until chosen ne -1
wset,chosen
cursor,xdum,ydum,/data,/nowait
end
pro trash2,xxxx
window,0
plot, findgen(10),title='window 0'
window,1
plot, findgen(10),title='window 1'
window,2
plot, findgen(10),title='window 2'
!mouse.button=1
while !mouse.button eq 1 or !mouse.button eq 4 do begin ;left and
right buttons on my mouse
wselect
; sub_cursor function below allows one to digitize a number of points
; x and y are arrays returned when right hand button of mouse is
depressed...
sub_cursor,x,y
;one exits from sub_cursor when !mouse.button is 4 or 2
endwhile ; center mouse button on my mouse is !mouse.button = 2
return
end
|