comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading mouse coordinates when using widgets
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: reading mouse coordinates when using widgets [message #3315] Thu, 15 December 1994 08:19
rep2857 is currently offline  rep2857
Messages: 28
Registered: December 1994
Junior Member
In article <D0p781.6uA@sci.kun.nl>, Chris Hendriks <chrish@cs.kun.nl> wrote:
>
> I use a drawing widget (wwdraw) and I want to retieve mouse coordinates in
> this drawing window. The procedure CURSOR does not seem to work for widgets.
> I use version 4.0. Any suggestions?
>
> Please reply to venvd@nlr.nl.
>

CC'd to venvd@nlr.nl

I'm a bit new to this, so any refinements to what I did are appreciated.

After creating the WwDrawing widget, you need to add some mouse
handlers. The WtAddHandler function manages this. The following code
statements ought to perform this for you.

@wtxlib ; this loads all of the button masks. You can also just assign
; the three mask names below to the values found in wtxlib.pro
drawwin = WwDrawing(drawwid, win, "drawinit", wsize, dsize, Area=d_area)
status = WtAddHandler(d_area, ButtonPressMask or ButtonMotionMask or $
ButtonReleaseMask, "draw_buttonevent", 0)

in draw_buttonevent you will need the following lines:
pro draw_buttonevent, wid, id, nparams, mask, event
x = event.x
y = event.y
; and likely several other lines for coordinate transformations
end

Mike Schienle Hughes Santa Barbara Research Center
rep2857@sbsun0010.sbrc.hac.com 75 Coromar Drive, M/S B28/87
Voice: (805)562-7466 Fax: (805)562-7881 Goleta, CA 93117
Re: reading mouse coordinates when using widgets [message #3320 is a reply to message #3315] Wed, 14 December 1994 05:40 Go to previous message
ao is currently offline  ao
Messages: 7
Registered: March 1994
Junior Member
idlusers-news-gateway:
id AA15967; Wed, 14 Dec 94 14:41:12 +0100
(5.67b/IDA-1.5 for idlusers@maz.sma.ch); Wed, 14 Dec 1994 14:39:15 +0100
Cc: venvd@nlr.nl

Hello Chris!

I will give two answers:

1. I have no problems using CURSOR in a big widget-application
with WIDGET_DRAWs. I didn't read the manual before writing
my applications and I find only, that positioning of the
cursor seems a little bit randomly, say values in a image_
cont - plot, where little squares have to show up one
value. Positioning of the cursor inside of the squares
return sometimes the value of the neighboured box.

2. Try this (as Stephen mentioned):

631 PRO MAIN13_Event, Event
...
634 COMMON INTERNA,xstart,ystart,xend,yend
635
636 WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
637
638 CASE Ev OF
639
...
658 'DRAW27': BEGIN
659 ; Some tests of mouse buttons
660 ; You can't check ... IF (event.press eq 1B) ... I don't know why!!
661 help,event,/struc
662 IF (event.press ne 0B) THEN BEGIN
663 xstart=event.x
664 ystart=event.y
665 ENDIF
666 IF (event.press eq 0B) THEN BEGIN
667 xend=event.x
668 yend=event.y
669 ENDIF
670 IF (event.release eq 1) THEN xyouts,xstart,ystart,'B',color=60,/device
671 IF (event.release eq 2) THEN plots,[xstart,xend],[ystart,yend], $
672 color=240,/device
673 IF (event.release eq 4) THEN xyouts,xend,yend,'E',color=120,/device
674 print,event.x,' ',event.y
675 no_draw_event: Print, 'Event for Drawing Area'
676 END
...
692 ENDCASE
693 END
694

824 PRO progname, GROUP=Group
...
834 MAIN13 = WIDGET_BASE(GROUP_LEADER=Group, $
835 COLUMN=1, $
836 MAP=1, $
837 TITLE='Evaluation Kit V 1.0 Copyright by EURAD', $
838 UVALUE='MAIN13', $
839 XOFFSET=20, $
840 YOFFSET=20)
...
984 DRAW27 = WIDGET_DRAW( BASE25, $
985 BUTTON_EVENTS=1, $
986 MOTION_EVENTS=1, $
987 RETAIN=2, $
988 UVALUE='DRAW27', $
989 XSIZE=600, $
990 YSIZE=400)
...
1165
1166 WIDGET_CONTROL, MAIN13, /REALIZE
1167
1168 ; Get drawable window index
1169
1170 COMMON DRAW27_Comm, DRAW27_Id
1171 WIDGET_CONTROL, DRAW27, GET_VALUE=DRAW27_Id
....
1893 XMANAGER, 'MAIN13', MAIN13
1894 END


This is an extraction from one of our widget_applications. It shall show
how to use the mouse-buttons via eventhandler. It's my first test and build
mainly by the new widget_builder of IDL 3.6.1

Hope that my explanation helps

Andreas O.

***

A question of me: Does anyone use the widget_builder of 3.6.1 under 3.5.1
on a PC. The author of the builder mentionend somewhere in the code, that
it's possible. But my IDL-Compiler is looking for wided.com file. What does
this mean? I can't find such a file on the 3.6.1 PC-Version.

***


EURAD-Administration
Postanschrift: Universitaet zu Koeln (GERMANY)
Institut fuer Geophysik und Meteorologie
- Projekt EURAD -
Atmosphaerische Umweltforschung
Dr.Andreas Oberreuter, Aachener Strasse 201-209, 50931 Koeln
Telefon: 0221 - 400 22 20 / 400 22 58 (Sekretariat)
Fax: 0221 - 400 23 20
E-Mail: ao@eurad.uni-koeln.de
Re: reading mouse coordinates when using widgets [message #3321 is a reply to message #3320] Wed, 14 December 1994 01:30 Go to previous message
zhsti is currently offline  zhsti
Messages: 1
Registered: December 1994
Junior Member
Hello,

Okay, this is absolutely correct. the manuals clearly explain that this will
create problems. Instead of doing this, use the events that can be generated by the draw widget. For information on this, see the widget_draw explaination in the manual. (I don't have one handy, and haven't been working directly so I cannot give you specifics. sorry)

-stephen


Chris Hendriks (chrish@cs.kun.nl) wrote:
:
: I use a drawing widget (wwdraw) and I want to retieve mouse coordinates in
: this drawing window. The procedure CURSOR does not seem to work for widgets.
: I use version 4.0. Any suggestions?
:
: Please reply to venvd@nlr.nl.
:

--
The opinions end ideas expressed here do not reflect those of my employeer
============================================================ =================
Stephen Strebel | Ski to Die
Union Bank of Switzerland | and Live to Tell about It
ORSE / OO Team Memeber |
email: stephen.strebel@zhflur.ubs.ubs.ch or strebel@alumni.cs.colorado.edu
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Keystroke events to a draw widget?
Next Topic: Need EOF code

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 16:24:10 PDT 2025

Total time taken to generate the page: 0.20992 seconds