396 views
in GUI Development by
Hi There,

I'm using EW 8.30.

I want to override HandleEvent method of Core::SlideTouchHandler. I have an instance of this object on my composer, which I call SlideHandler. I go to the Core::SlideTouchHandler class, right-click on HandleEvent method, and select 'copy'.

Then I go to my composer, right-click, and select 'Derived Paste'. This is fine, and I have my own method for HandleEvent now.

The problem, is that when I execute the application, both SlideHandler.HandleEvent (my implementation) AND Core::SlideTouchHandler.HandleEvent fire !

I don't want Core::SlideTouchHandler.HandleEvent to fire, I have overidden it, and I want my derived method only to fire.

Please, what am I doing wrong here?

Regards,

Rob Shand
by
So I see that HandleEvent is already inherited from Core::View. Because I do a derived paste, it becomes a second inherited method, so both the inherited method in Core::SlideTouchHandler and SlideHandler fire. My question becomes: "How then can I replace Core::SlideTouchHandler.HandleEvent with my own implementation?"

1 Answer

0 votes
by

Hello Rob,

according to your question you intend to override the HandleEvent method existing in the Mosaic class Core::SlideTouchHandler. For this purpose you have to derive a new class from Core::SlideTouchHandler and override there the HandleEvent method. The new class should be stored in one of your own units.

Once you have the new class implemented, you can add instances of this new class wherever you expect this modified functionality. Since the class is derived from Core::SlideTouchHandler, it inherits its functionality. Alternative approach is to change the Class attribute of already existing Slide Touch Handler objects to correspond to your new class. In this way you can manage some handlers using your own modified implementation and other using the original version.

Does it help you further?

I don't know the reason why you want to modify the implementation of the original Slide Touch Handler. But, maybe, it would be better to create your own handler class? The classes Core::RectView, Core::QuadView and Core::LineView are the very basic classes for all other views existing in Embedded Wizard. If you plan to design a special kind of touch handler, you can derive a new class from e.g. Core::RectView and implement your own special handler from scratch.

Another, more sophisticated, approach is to override the class Core::SlideTouchHandler by a class variant. with a VariantCond attribute set true. With this approach you modify the functionality of the original class so that this functionality automatically affects all instances of the original class. In other words, you inject code into the original class. This approach is thus ideal if you want the modification to affect all instances of the handler existing in your entire project. Please note: this here explained class variant approach works for EmWi >= 9.30. Before 9.30 all members existing in the unit Core (thus also the SlideTouchHandler) were not permitted to be overriden by a class variant. Thus the usage of this approach depends on the version of your Embedded Wizard Studio.

Best regards

Paul Banach

by
Super, thank you Paul !

Regards, Rob

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...