comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Widget_event and a TLB object !!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Widget_event and a TLB object !!! [message #44350] Mon, 13 June 2005 07:55 Go to next message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Hi I am very desperated with a widget object based I'm writting.
This is the situation:

I want to create an object that in its INIT method creates a WIDGET_BASE
with some buttons a text widgets. I wnat to collect some values, then
the user close (unmap) the widget_base, recollect the values with some
object method (GetProperty) and destroy the object.

Well, the problems comes with event handler. I can use XMANAGER because
it cant bring the use of methods, then I tried to use WIDGET_EVENT, but
I had a lot of problems to resolve the situation. Now I know where it
fails but no why it fails :(

Initialy, I assoaciated to the WIDGET_BASE an EVENT_PRO procedure
(extracted from this http://www.rsinc.com/codebank/search.asp?FID=209
from JP). This procedure is responsible to send ocurred events into the
widget_Base to a method of my object (MyObject::Event_Handler). Well
this is part of the code (I attach all it):

FUNCTION NewProcess::Init

base = WIDGET_BASE(/COLUMN, $
TITLE='New Process Wizard', UVALUE=self, $
EVENT_PRO='GenericClassEventHandler')

;;Create widgets
content = WIDGET_BASE(base, XSIZE=cxsize, YSIZE=cysize, $
X_SCROLL_SIZE=cxsize, Y_SCROLL_SIZE=cysize)
text = WIDGET_TEXT(content, XSIZE=20, YSIZE=30)

line = WIDGET_BASE(base, XSIZE=500, YSIZE=0, /FRAME)

buttons = WIDGET_BASE(base, /ROW)
previous = WIDGET_BUTTON(buttons, VALUE='< Previous', $
UVALUE='PREVIOUS', SENSITIVE=0)
next = WIDGET_BUTTON(buttons, VALUE='Next >', UVALUE='NEXT', $
SENSITIVE=1)
finish = WIDGET_BUTTON(buttons, VALUE='Finish', UVALUE='FINISH', $
SENSITIVE=0)
cancel = WIDGET_BUTTON(buttons, VALUE='Cancel', UVALUE='CANCEL')

;;Store references
self.base = base
self.content = content
self.previous = previous
self.next = next
self.finish = finish
self.cancel = cancel

WIDGET_CONTROL, self.base, /REALIZE

event = WIDGET_EVENT(self.base)
print, 'Never shows this line'

;;Event Loop
; WHILE NOT self.destroy DO BEGIN
; event = WIDGET_EVENT(base)
; self->EventHandler, event
; ENDWHILE

RETURN, 1
END


Why WIDGET_EVENT call never returns ??? I dont know if I missunderstand
the doc, but I though WIDGET_EVENT gets the event, call the EVENT_PRO
associated with my WIDGET_BASE and returns.

To test it execute:

p = OBJ_NEW('NewProcess')

and press NEXT button and later CANCEL button.

Finally, I had removed the EVENT_PRO from the WIDGET_BASE, uncomment the
above comment code and comment the line "event=WIDGET_EVENT...".




Thanks in advice,
Antonio (a little upset :( )

--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------

;+
; @FILE_COMMENTS Answer the information needed to create a new
; process.
;
; @AUTHOR
; Antonio Santiago
; http://www.grahi.upc.edu/santiago - <santiago\@grahi.upc.edu>
; <asantiagop\@gmail.com>
;
; @HISTORY
; Fri Jun 10 13:31:13 2005, Antonio Santiago
; (santiago\@grahi.upc.edu - asantiagop\@gmail.com)
;-


;+
; Event handler
;
; @PRIVATE
;
; @PARAM event {in}{required}{type=event struct} Event stucture with
; produced information.
;-
PRO NewProcess::EventHandler, event

WIDGET_CONTROL, event.id, GET_UVALUE=uval

IF ~N_ELEMENTS(uval) THEN RETURN

CASE uval OF
'NEXT': BEGIN
print, 'next'
END

'CANCEL': BEGIN
;self.destroy = 1
WIDGET_CONTROL, self.base, /DESTROY
END

ELSE: ;Nothing
ENDCASE
END


;+
; @FILE_COMMENTS This routine is called when an event occurs in any
; object-based TLB (Top-Level Bases). The 'EventHandler'
; method of the
; class whose object reference is stored in the
; 'event.handler's UVALUE is called.</br></br>
; <i>This is a personal modification of the
; 'generic_class_event.pro' procedure created by Jim
; Pendleton (jimp\@rsinc.com). You can find the original
; code in the RSI User Contribution page.</i>
;
; @PARAM event {in}{required}{type=structure} The widget event produced.
;
; @EXAMPLES
; Inside your object-based TLB use WIDGET_CONTROL to associate this
; procedure as the events ocurred in the widget:
; <pre>
; ...
; WIDGET_CONTROL, the_widget, SET_UVALUE = self,
; EVENT_PRO='Generic_Class_Event'<br>
; ...
; </pre>
;-
PRO GenericClassEventHandler, Event
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 "EventHandler".
oSelf->EventHandler, event
ENDIF
ENDIF
END


;+
; Show plugin informacion stored in a PluginInfo object.
;
; @PARAM wbase {in}{required}{type=long} Widget base where to put the
; information.
;-
FUNCTION NewProcess::Init

base = WIDGET_BASE(/COLUMN, $
TITLE='New Process Wizard', UVALUE=self, $
EVENT_PRO='GenericClassEventHandler')

;;Create widgets
content = WIDGET_BASE(base, XSIZE=cxsize, YSIZE=cysize, $
X_SCROLL_SIZE=cxsize, Y_SCROLL_SIZE=cysize)
text = WIDGET_TEXT(content, XSIZE=20, YSIZE=30)

line = WIDGET_BASE(base, XSIZE=500, YSIZE=0, /FRAME)

buttons = WIDGET_BASE(base, /ROW)
previous = WIDGET_BUTTON(buttons, VALUE='< Previous', $
UVALUE='PREVIOUS', SENSITIVE=0)
next = WIDGET_BUTTON(buttons, VALUE='Next >', UVALUE='NEXT', $
SENSITIVE=1)
finish = WIDGET_BUTTON(buttons, VALUE='Finish', UVALUE='FINISH', $
SENSITIVE=0)
cancel = WIDGET_BUTTON(buttons, VALUE='Cancel', UVALUE='CANCEL')

;;Store references
self.base = base
self.content = content
self.previous = previous
self.next = next
self.finish = finish
self.cancel = cancel

WIDGET_CONTROL, self.base, /REALIZE

event = WIDGET_EVENT(self.base)

print, 'Never shows this line'

;;Event Loop
; WHILE NOT self.destroy DO BEGIN
; event = WIDGET_EVENT(base)
; self->EventHandler, event
; ENDWHILE

RETURN, 1
END


;+
; Frees the memory used by the object.
;-
PRO NewProcess::Cleanup
WIDGET_CONTROL, self.base, /DESTROY
END


;+
; Newprocess class definition.
;
; @PRIVATE
;-
PRO NewProcess__define

struct = {NewProcess, $
base: 0L, $
content: 0L, $
previous: 0L, $
next: 0L, $
finish: 0L, $
cancel: 0L, $
destroy: 0B $
}
END
Re: Widget_event and a TLB object !!! [message #44421 is a reply to message #44350] Tue, 14 June 2005 04:06 Go to previous message
Robert Moss is currently offline  Robert Moss
Messages: 74
Registered: February 1996
Member
Antonio Santiago wrote:
> Hi I am very desperated with a widget object based I'm writting.
> This is the situation:

This seems to me like a problem that is screaming for a modal widget. If
this object widget is supposed to pop up, get used, then go away, a
modal widget will do the trick nicely. I use this type of modal object
widget all the time to get input parameters for complicated procedures.

r

Robert Moss, PhD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Determine if class has method/property
Next Topic: IDL source editor alternatives?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:17:17 PDT 2025

Total time taken to generate the page: 0.00754 seconds