Re: widget event structure doesn't transfer [message #81134 is a reply to message #81051] |
Tue, 14 August 2012 18:29   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Kat writes:
> I have the book and it's definitely my go-to widget guide. I have a
bit of an idea how to run normal widgets using procedures but once I try
to figure out the functions and these popup dialogs it's like a whole
new ballgame (I am also a little slow haha so I'm sure that doesn't
help). I've looked at the Pop-up Dialog page a lot and though I get the
overall idea, I'm not sure how to carry it out.
>
> For example, textbox is defined:
> FUNCTION TextBox, Title=title, Label=label, Cancel=cancel, $
> Group_Leader=groupleader, XSize=xsize, Value=value
>
> but if I want it to launch when i click a button, the code (and i'm assuming this is how i would call it):
> w_userRoi= widget_button(p,value = 'Get User Defined ROI',frame = 2,$
> event_func = 'textbox')
> wouldn't have anywhere to input the various arguments. How would I put those in the function? (i tried taking them all out and calling it that way, but I'm still getting an "incorrect number of arguments" error"). But either way, I do want to have at least one argument.
Event handler routines (what you are defining with the EVENT_FUNC or
EVENT_PRO keywords) are all written in exactly the same way: with one
and only one parameter, which is the event structure that the window
manager passes to it. In general, you never call event handlers
yourself. They are called for you.
What you *do* in an event handler is entirely up to you.
You could, for example, call any other IDL procedure or
function you wanted to, including those that implement
other widget programs. You can pass these IDL procedures
and functions any variables that you have defined in the
context of the procedure or function, via either arguments
or keywords.
> Also, do I even need all those?
You need whatever makes sense for the program you are calling.
That's all you need.
> All I want the function to use is the uservalues of the original
widget (since I want to do stuff with those), and I guess the Cancel
variable. But then there's the issue of not knowing how to call the
function correctly.
You call it exactly like you would call any other function in IDL,
passing appropriate arguments and keywords.
> Finally, where does my return value save to? Would it be w_userRoi, or somewhere else?
If it is information that is only going to be used in that
event handler module, you don't have to save it anywhere. Just
use it. If it is information that you are going to need to run
your program, then you save it in the info structure will all
the other stuff you need to run your program.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|