Widget Event_Pro question [message #59480] |
Mon, 31 March 2008 04:29  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
Hi guys,
As part of a little image display programme, I've currently got a draw
widget:
Display = WIDGET_DRAW(Base, XSIZE = S[0], YSIZE = S[1], $
/MOTION_EVENTS, EVENT_PRO = 'SLIDESHOWWIDGET_GETVALUES')
And I'd like to add button events to it. I don't want to get rid of
the motion events though. The easiest way that I can think of adding
functionality is to (ideally) have two Event_Pro strings, one to be
run if a motion event is detected, another if a mouse click is
detected. The two are going to do fairly different things here.
(If you're interested: the motion event will just update 3 labels
within the widget base to show x & y position and image intensity at
that point; whereas the click should start up a second, blocking
widget that's going to draw me a graph of image intensity change over
time at that point.)
Is there a way of doing this?
...perhaps by calling to widget_draw or even widget_control a second
time and defining a different Event_Pro? Can I even just superimpose a
second draw widget over the whole thing and give it its own event_pro?
I'd suspect that this latter approach would give it (my 2nd draw
widget) a different Window Index and mess things up royally at the
user interface :-(
Or am I just stuck making my SLIDESHOWWIDGET_GETVALUES programme big,
confusing and unwieldy?
Regards,
Chris
|
|
|
Re: Widget Event_Pro question [message #59593 is a reply to message #59480] |
Wed, 02 April 2008 09:10  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Apr 2, 4:47 pm, David Fanning <n...@dfanning.com> wrote:
> Spon writes:
>> I think I'm already doing what you suggest, but just to be sure:
>
>> Graphs = PTR_NEW([-1L])
>
> I wouldn't do this. If there is nothing in it, I would
> probably make it a null pointer:
>
> graphs = PTR_NEW()
>
> Then check to see if I had a valid pointer in my code
> before I used it.
>
> Or, if you *want* a valid pointer, but don't have anything
> to put in it, you can just do this:
>
> graphs = Ptr_New(/ALLOCATE_HEAP)
>
> Now, you have a valid pointer:
>
> IDL> Print, Ptr_Valid(graphs)
> 1
>
> But, the thing inside it is an undefined variable:
>
> IDL> help, *graphs
> <PtrHeapVar1> UNDEFINED = <Undefined>
>
> You can stick something in it:
>
> *graphs = [widgetID]
>
> You can even find out how many things are in it:
>
> IDL> Print, N_Elements(*graphs)
>
>> Oh, and another question while I'm at it: I'm trying to check if a
>> widget still exists before trying to load its UVal, I thought that
>
>> IF WIDGET_INFO(GraphUVal.GroupLeader, /ACTIVE) THEN BEGIN
>
>> would do what I want, but apparently the /ACTIVE keyword doesn't work
>> with an argument.
>
> I don't know what ACTIVE does. The keyword you want
> is VALID_ID.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Thanks David, you're a great help as usual :-)
Chris
|
|
|
Re: Widget Event_Pro question [message #59598 is a reply to message #59480] |
Wed, 02 April 2008 08:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Spon writes:
> I think I'm already doing what you suggest, but just to be sure:
>
> Graphs = PTR_NEW([-1L])
I wouldn't do this. If there is nothing in it, I would
probably make it a null pointer:
graphs = PTR_NEW()
Then check to see if I had a valid pointer in my code
before I used it.
Or, if you *want* a valid pointer, but don't have anything
to put in it, you can just do this:
graphs = Ptr_New(/ALLOCATE_HEAP)
Now, you have a valid pointer:
IDL> Print, Ptr_Valid(graphs)
1
But, the thing inside it is an undefined variable:
IDL> help, *graphs
<PtrHeapVar1> UNDEFINED = <Undefined>
You can stick something in it:
*graphs = [widgetID]
You can even find out how many things are in it:
IDL> Print, N_Elements(*graphs)
> Oh, and another question while I'm at it: I'm trying to check if a
> widget still exists before trying to load its UVal, I thought that
>
> IF WIDGET_INFO(GraphUVal.GroupLeader, /ACTIVE) THEN BEGIN
>
> would do what I want, but apparently the /ACTIVE keyword doesn't work
> with an argument.
I don't know what ACTIVE does. The keyword you want
is VALID_ID.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Widget Event_Pro question [message #59600 is a reply to message #59480] |
Wed, 02 April 2008 08:38  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Apr 2, 4:23 pm, David Fanning <n...@dfanning.com> wrote:
> Spon writes:
>> I need to define this array before any instances of widget B are open.
>> Can I use a value of [-1L] for this? Or is -1 a valid widget ID number
>> that might cause problems later if IDL decides to label one of my
>> widgets -1 at some point?
>
> All widget IDs are positive. But, a pointer comes
> to mind, too. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
I think I'm already doing what you suggest, but just to be sure:
Graphs = PTR_NEW([-1L])
UVal = {Img:Img $
... ;
... ; Loads of other garbage
Graphs:Graphs }
WIDGET_CONTROL, Base, SET_UVALUE = UVal
And then, when I realize a graph widget:
; Register the widget with top level UVal structure
*UVal.Graphs = [(*UVal.Graphs), GraphBase]
WIDGET_CONTROL, Event.Top, SET_UVAL = UVal
; Register top level widget ID in Graph widget UVAL
GraphUVal = { GroupLeader:Event.Top }
WIDGET_CONTROL, GraphBase, SET_UVAL = GraphUVal
Is this what you meant by using a pointer? Or could I do it more
efficiently? The main problem this creates is in my graph deleting
procedure, where I have to first check if the array contains any non-
minus-one entries and then loop through them all, destroying the
associated widgets and reseting them to -1.
Oh, and another question while I'm at it: I'm trying to check if a
widget still exists before trying to load its UVal, I thought that
IF WIDGET_INFO(GraphUVal.GroupLeader, /ACTIVE) THEN BEGIN
would do what I want, but apparently the /ACTIVE keyword doesn't work
with an argument.
Chris
|
|
|
Re: Widget Event_Pro question [message #59601 is a reply to message #59480] |
Wed, 02 April 2008 08:23  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Spon writes:
> I need to define this array before any instances of widget B are open.
> Can I use a value of [-1L] for this? Or is -1 a valid widget ID number
> that might cause problems later if IDL decides to label one of my
> widgets -1 at some point?
All widget IDs are positive. But, a pointer comes
to mind, too. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|