Re: Update text widget [message #65244 is a reply to message #65243] |
Thu, 19 February 2009 06:27   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
titan writes:
> I'm trying to write my own first widget but probably I'm missing
> something about the event handler.
>
> I would like to create a widget text with 4 rows. these rows are
> created as insensitive and I would like to make them sensitive when
> each of these processes occur.
>
> How can I "communicate" to my widget that the process started and
> after some calculations it is finished and then update my widget???
You can "communicate" with a widget by sending it
events. These events can be generated by graphical
user interface objects (buttons, text widgets, and
the like), or you can just make up an event and send
it to a widget, assuming you know the identifier of
that widget, with Widget_Control and the SEND_EVENT
keyword.
Your widget has not been built in a way that will generate
any events, so you are unlikely to ever find yourself
in your event handler. :-)
A good thing, too, since as was pointed out, you are
using variables in your event handler (text, text1_,
and text1_msg) that are not defined in that procedure.
IDL does not take kindly to using undefined variables in
expressions. :-(
So, the first thing you need to learn is how to get information
you need in the event handler *into* the event handler. One way
information comes into your event handler is via the event
structure. But the event structure contains extremely limited
information. It will not know the identifiers of any of your
text widgets, for example. And without those identifiers, you
have absolutely no way of interacting with them, since the ONLY
way of interacting with widgets is via their identifiers.
There are a couple of ways of getting the information you need
where you need it. But the idea that comes immediately to mind,
common blocks, is the worst possible one. :-)
Go to some reputable web site (I could suggest one if you can't
find one) and find a widget program. See how information is passed
in that program. And I would locate a good book on IDL, too. I think
it will be extremely difficult to learn to write decent widget programs
if all you have to go on is the IDL documentation.
Widget programming is not difficult, once you get your head around
how events happen and are processed (one at a time), and how to
find the information you need to do whatever it is you need to do.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|