comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: Classes and Widget Event Handlers...

Re: Classes and Widget Event Handlers...
type: item
description: David Morris, dmorris@ball.com writes: > The event-handler for the widget needs to have access to > all of the variables of the class, and it must have direct > access to them. Unfortunately, XMANAGER (as far as I can > tell) does not allow the use of object method-routines as an > event handler. If you make your widget an object that inherits the class whose variables you want to access, it can do so by using the standard self.xxx syntax. If you want the object to have a life of it's own beyond that of the widget you will have to make a way for the widget to swallow and regurgitate the object when it is created and killed. Your only other option is to write a generalised GET/SET_PROPERTY method like those used in the objects graphics classes. This seems to have come up a lot recently, so here's Mark Rivers' (rivers@cars.uchicago.edu) original example of how to make an widget into an object: > > IDL Objects really simplify complex widget programs, > because so don't have to create a "state" structure and > stick in the uvalue of a top level widget. Just put the > object reference to "self" there instead. This is not > entirely obvious, and the Object manual does not have an > example, so here is how I do it. > > ;; File example__define.pro > > function example::init > base = widget_base(uvalue=self) > self.widgets.base = base > self.widgets.exit = widget_button(base, value='Exit') > widget_control, base, /realize > xmanager, 'example::init', base, event='example_event', /no_block > return, 1 > end > > pro example_event, event > ; Note: The main event handler CANNOT be an object method, > , since xmanager won't know how to call it as such. However, > ; it only needs to be 4 lines long: retrieve the object > ; reference and call the object method event handler, > ; which will know about the objects data structure. > widget_control, event.top, get_uvalue=object > object->event, event > end > > pro example::event, event > ; This is the event handler which knows about th…
creator: Struan Gray
date: 1999-07-03T07:00:00-00:00