How to stop handling event

I guess this is something simple, but I really cannot find answer to this.

I want to draw something with mouseclick/drag on TImage (actually astroroot AstroImage). Normally dragging mouse on this object causes zooming. I am handling the mouse motion event myself, but than it zooms anyway.

How can I stop processing event after I processed it myself? In other words: how to prevent zooming?

Thanks for an answer.

We need more info from your side. Did you see with the AstroImage authors ?

Rene

I guess I wasn’t specific enough.

I think that’s connected to TImage in general. I tried it with psview.C from tutorials - you can zoom indragging with mouse. I want to do something else instead of zooming. How to prevent this zooming?

This zoom facility is build in the method:

void TASImage::ExecuteEvent(Int_t event, Int_t px, Int_t py)

Each time a TImage is encountered these method is called. Can you inactivate it in some way ? have you access to the code or the AstroImage authors ?

I guess a other way would be to draw an pad on top of the TImage like that the TImage will not be seen and therefore this method will not be called.

[quote=“couet”]This zoom facility is build in the method:

void TASImage::ExecuteEvent(Int_t event, Int_t px, Int_t py)

Each time a TImage is encountered these method is called. Can you inactivate it in some way ? have you access to the code or the AstroImage authors ?
[/quote]

I can ofcourse mofidy AstroImage or inherit my own class. But I doubt that’s a proper method to do this…

[quote=“couet”]
I guess a other way would be to draw an pad on top of the TImage like that the TImage will not be seen and therefore this method will not be called.[/quote]

That’s a workaround… But I understand, that each time TImage is encountered, an ExecuteEvent method is called, which calls TImage::Zoom() and other event handling, including my procedures. Therefore it’s just a matter of interrupting this event handling queue. I am far from being a programmer, but I know that in many GUI libraries, like, for example, wxWidgets, you stop event propagation in proper place with one simple function.

The question is: can I do such a thing in Root?

That’s the basic of ROOT: each object as a DistanceToPrimitive and ExecuteEvent method. The 1st one allows to detect if an object is touched by the mouse the second execute the proper actions connected to this object. If you look at the ExecuteEvent method of TASimage you will see that the Zoom is part of it. That’s build in the code. That’s not a matter of “Event handling”. In my view the only to way are: Rewrite ExecuteEvent (inheriting is one way) or make the TImage unpickable by hiding it behind a pad.

Hmm, and is there a way to “disconnect” those ExecuteEvent functions? I mean, same as with Disconnect(). That would help, I think…

And there is a way to avoid zooming, but I cannot figure out how it is done. If I open canvas toolbar, than select a figure, I can draw the figure on top of TImage with mouse drag, not causing TImage to be zoomed…

Is this the trick with pad, or a trick with event handling?

When you enter the toolbar editor you then click on a primitive to be created and then that is treated in TPad::ExecuteEvent(Int_t event, Int_t px, Int_t py) (the TCreatePrimitives::XXX calls), so that is from inside a particular ExecuteEvent method : The TPad one.

But can you perheaps give me a clue, how it is done, that after clicking a primitive, TPad ExecuteEvent is called, not TImage ExecuteEvent? Even though I’m clicking on TImage?

I guess that could be an answer to my primary question :slight_smile:

When you click on a primitive in the toolbar the EditorMode is set and
TPad::ExecuteEvent handles it (see the code). Within this method the primitive creation is done by calling the corresponding TCreatePrimitives method (see the code). So
TASImage::ExecuteEvent is never called because TPad::ExecuteEvent does the primitive creation before and then exit.

Thanks. Seems I may be able to do what I want with SetEditable()… However, maybe in some far future, such event handling I mentioned would be something worth implementing.

Currently I have some problems refreshing TASImage, but that’s explained in different thread.

Yes, depending what you are doing SetEditable is an option. I did not mentioned it earlier because in the little test case I had it does not really seem to do what you asked (at least what I understood you asked).

Maybe I made this a little bit difficult to understand at some stage :slight_smile: My aim was to prevent zooming and SetEditable() prevents zooming and I can still do other things in the code. It does not explicitly do anything with events, but it must do that somewhere deeper.