[vtkusers] check for pending tk events

David Gobbi dgobbi at imaging.robarts.ca
Tue Jul 23 13:58:32 EDT 2002


On Tue, 23 Jul 2002, Kevin Wright wrote:

> At 12:00 PM 7/23/2002 -0400, you wrote:
> >Hi All,
> >
> >I'm looking for a way to abort a render if a user interacts with the
> >window, and the easiest way seems to be for the window's AbortCheck
> >method to check if there are any tk events pending.
> >
> >Is there a way, either in raw tk or within the vtkTkRenderWidget, to
> >check if there are events pending?  I've searched the tk documentation
> >with no luck.
>
> I've never tried this, so I'm not entirely sure it would work, but I think
> if you call Tcl_DoOneEvent with flags set to make it only process window
> events, and not to wait, if there are no window events present, it will
> return 0, otherwise it will process one event and return 1.  So something
> like this, I think:
>
> if ( Tcl_DoOneEvent ( TCL_DONT_WAIT | TCL_WINDOW_EVENTS ) ) {
>    // BAIL OUT
> }
>
> As long as you don't mind processing the next event on the queue.  If you
> don't want to do that, then you can actually get a handle to the event
> queue itself and work along the linked list looking for certain events, but
> I'm afraid I wouldn't be much help with that.  Look in tclNotify.c for some
> of the code that controls the event queue itself.
>
> Hope that helps,
> Kevin.

If it involves doing C programming, then it would be easier for me to
check for pending events using operating-system level code inside of
vtkTkRenderWidget.cxx than mess around with Tcl.  In raw Win32 and X
it is very straightforward to check for events.

Thanks for your answer.  It looks like aborting a vtkTkRenderWidget
render might be more trouble than it is worth.

 - David




More information about the vtkusers mailing list