Re: Loading picture into compound widget [message #31875] |
Tue, 27 August 2002 08:32  |
MKatz843
Messages: 98 Registered: March 2002
|
Member |
|
|
David's correct (goes without saying). Learning to code your own
widgets is the way to go. In the mean time, I think I can offer a
simple, perhaps ugly, fix. (Note: I would never recommend this as a
way to begin programming widgets, it's just a suggestion to get you up
and running with what you've already got.)
It seems that the widget code does not make use of the very useful
UVALUE (User Value) field in the widgets. One can store important
information there--any type.
So as a temporary fix, once you learn the window number (index) you
can store it in the UVALUE of one of your widgets, like this. In the
line following
WIDGET_CONTROL, drawViewer, GET_VALUE = index
put
WIDGET_CONTROL, menuFileOpen, SET_UVALUE=index ;-- new line
I've chosen to store the value in the menuFileOpen widget because
that's
the one that's generated the event. We'll know its ID from within the
event handler routine and it's in the Event structure as Event.ID.
So, change your OnOpen routine to
pro OnOpen, Event
ImageIsRead=DIALOG_READ_IMAGE(DIALOG_PARENT=Event.top, $
FILE=FileName, FILTER_TYPE='.tif, .tiff', IMAGE=PhotoArray, $
TITLE='Choose the photo file')
IF (ImageIsRead EQ 1) THEN BEGIN
;--- Ask the menuFileOpen widget to give you back the index value
; you stored.
WIDGET_CONTROL, Event.ID, GET_UVALUE=uval
WSET, uval
TVSCL, PhotoArray
ENDIF
end
It ain't pretty, but that should work for now.
M. Katz
|
|
|