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
|
|
|