Re: xmanager to call object methods? [message #39127 is a reply to message #39118] |
Wed, 21 April 2004 08:16   |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
>>>> > "Oliver" == Oliver Thilmann <justspam03@yahoo.de> writes:
> Hi, is there any generic way to handle events via objects,
> i.e. make xmanager (or something like it) call an object
> method instead of a function or procedure?
> The reason is that in my current design, I use the uvalue
> of evt.top to store a reference to the object currently
> handling UI input in the respective window and then call
> the event-handler of that object from an intermediate
> function. Alas, that's not possible in all cases. Without
> going into details: I ended up trying to pull myself out of
> the swamps by my own hair as Munchhausen did.
There is generic_class_event in the RSI user-contrib ligbrary
http://www.rsinc.com/codebank/search.asp?FID=209 . (and I'll
stick a copy below...)
Mike
--
Michael A. Miller mmiller3@iupui.edu
Imaging Sciences, Department of Radiology, IU School of Medicine
;+
; This routine is called when an event occurs in any object-based TLB.
; In turn, the ::EVENT method of the class whose object reference is
; stored in the EVENT.HANDLER's UVALUE is called.
;
; @Param
; Event {in}{required}{type=structure}
; Any sort of IDL GUI event
;
; @Examples
; <pre>
; Widget_Control, TLB, Set_UValue = self, Event_Pro = 'Generic_Class_Event' <br>
; XMANAGER, 'GENERIC_CLASS', TLB
; </pre>
;
; @History
; June, 2001 : JLP, RSI
;-
Pro Generic_Class_Event, Event
COMPILE_OPT STRICTARR
Widget_Control, Event.Handler, Get_UValue = oSelf
If (N_elements(oSelf) eq 1) then Begin
If (Obj_Valid(oSelf)) then Begin
;
; A class that uses this routine must have a method
; named "::EVENT".
;
oSelf->Event, Event
EndIf
EndIf
End
|
|
|