Re: XLoadCT in a procedure ????? [message #5288] |
Fri, 17 November 1995 00:00 |
Ken Knighton
Messages: 44 Registered: May 1995
|
Member |
|
|
jgm@nntp.unsw.EDU.AU (Julian Marshall) wrote:
> Hi.
> I have a slight problem with Xloadct. It does not behave well
> when used inside a case statement in a procedure. When Xloadct
> is in a procedure, the pro naturally waits for xloadct to be
> finished before continuing, but when I use Xloadct within a
> case statement, the event handler does not seem to wait for
> the Xloadct pro to finish.
>
> The relevant part of my code is:
>
> PRO jv_event, event
> Widget_control, event.id, GET_Uvalue=eventval
> CASE eventval of
>
> 'COLOUR':Begin
> XLoadCT
> TvLCT, r1,g1,b1,/GET
> XLoadCT
> TvLCT, r2,g2,b2,/GET
> Combine_CT ;calls another procedure
> END
> ENDCASE
> END
>
The problem is that XLoadCT is like most widget applications, it uses the
Xmanager to handle its events. If you use XLoadCT in a situation in which
the XManager has not already been initiated, then it doesn't return until
the widget is destroyed causing the XManager's loop to exit. In the above
situation, you are calling XLoadCt from within the event handler of a
widget application. XLoadCt is simply registered as another widget to be
managed by the XManager and because this isn't the first time XManager was
called, Xmanager returns and therefore XLoadCt also returns.
There are probably numerous ways to get around this problem, but I'm going
to give you a quick hack:
Copy off the XLoadCT procedure from the IDL distribution library. You
may want to rename it so that you don't get the two confused. Then edit
your personal version of XLoadCt to change the following line from:
XManager, "xloadct", base, GROUP_LEADER = GROUP
to:
XManager, "xloadct", base, GROUP_LEADER = GROUP, /MODAL
It would be nice if XLoadCt came with a modal keyword, but it doesn't.
You could go a little further than the above solution and add a MODAL
keyword to your version of XLoadCt. This would have the advantage that
XLoadCt would work normally unless you wanted it to be a modal dialog box.
I hope this helps.
Ken Knighton knighton@gav.gat.com knighton@cts.com
Fusion Division
General Atomics
San Diego CA
|
|
|
Re: XLoadCT in a procedure ????? [message #5289 is a reply to message #5288] |
Fri, 17 November 1995 00:00  |
rivers
Messages: 228 Registered: March 1991
|
Senior Member |
|
|
In article <48esa3$8a3@mirv.unsw.edu.au>, jgm@nntp.unsw.EDU.AU (Julian Marshall) writes:
> Hi.
> I have a slight problem with Xloadct. It does not behave well
> when used inside a case statement in a procedure. When Xloadct
> is in a procedure, the pro naturally waits for xloadct to be
> finished before continuing, but when I use Xloadct within a
> case statement, the event handler does not seem to wait for
> the Xloadct pro to finish.
I don't believe that your statement "When Xloadct is in a procedure, the pro
naturally waits for xloadct to be finished before continuing" is correct.
XloadXT creates its widgets and then just registers itself with Xmanager, and
immediately returns. In many applications this is the way one wants it to work.
Pressing the "Change Color" button on an application pops up XloadCT, which
then stays around, allowing the use to change colors whenver they want, i.e.
they don't have to press "Change Color" again. There is probably a way to get
the behavior you want, i.e. the program waits until the user exits XloadCT,
perhaps by making a "modal widget" which calls XloadCT.
____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
|
|
|