Re: programming with widgets [message #66390] |
Wed, 13 May 2009 08:31 |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
OK, finally !!!!
This is the best way. I tried something similar and I realized that I
can't retrieve the uvalue info of the widget_base after destroy it.
Moreover, the info structure that you use in the example is not
available after the XMANAGER definition line.
You are using a pointer to save this information and when the widget
id.TOP dies you can obtain the result of your value anyway.
Thanks, my confusion is gone.
nata
|
|
|
Re: programming with widgets [message #66393 is a reply to message #66390] |
Wed, 13 May 2009 06:18  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nata writes:
> I wanted to create a FUNCTION for display a list of options. The user
> selects one option and the FUNCTION returns it.
> The best way I found to do that is using a COMMON statement. I store
> in the COMMON the variable who I'll return and I share this COMMON on
> the EventHandler method. When the widget is closed, the only think
> I've to do is return the content of the COMMON block.
Well, that's one way. There are others. :-)
http://www.dfanning.com/widget_tips/popup.html
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.")
|
|
|
Re: programming with widgets [message #66395 is a reply to message #66393] |
Wed, 13 May 2009 06:02  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Hi David,
I wanted to create a FUNCTION for display a list of options. The user
selects one option and the FUNCTION returns it.
The best way I found to do that is using a COMMON statement. I store
in the COMMON the variable who I'll return and I share this COMMON on
the EventHandler method. When the widget is closed, the only think
I've to do is return the content of the COMMON block.
Using this method I call only a function in order to obtain the
result.
Thanks
nata
|
|
|
Re: programming with widgets [message #66400 is a reply to message #66395] |
Tue, 12 May 2009 17:58  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nata writes:
> I'm a little bit confused when I use widgets..
> To create a widget, sometimes I use objects with a function called
> GenericClassEventHandler.
> Something like this:
> function widget::Init()
> self.base=widget_base(uvalue=self)
> ...
> xmanager, 'widget', self.base,
> event_handler='genericclassevent_handler'
> return,1
> end
>
> Sometimes I create procedures using the state structure in a User
> Value. For example:
> ...
> state={var_a: 0l, var_b: 0l}
> widget_control, base, set_uvalue=state, /no_copy
> ...
> I don't know which is the best option to preserve the application
> state and some variables...
>
> Now, I need to create a widget to display a list of options. The user
> will select one option and he'll close the widget. Something like the
> DIALOG_MESSAGE() using the QUESTION keyword.
> Something like this: result=MY_WIDGET(options)
>
> So, for do that, which is the best option?? Any ideas or
> suggestions ?
I'm a bit confused when I read your question. :-)
It seems to me what you want is a pop-up dialog widget,
which just collects information from a user and returns
it to the caller of the function. If that is the case,
I don't think it much matters how you write it. Whichever
way is faster for you, I guess.
But if you want to store the information somewhere, so
it can be retrieved later (some kind of "configuration"
object), then I think I would write this as an object
with storage for the parameters of interest and a "GUI"
method that could implement the pop-up dialog part of
the program.
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.")
|
|
|