We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Group Base Class an OnMouseClick() Event

Hi,

I have a number of classes derived from the Group class. In this "example" I have 3 bitmapnodes, each of which acts like a button. So I want my class to raise a different event based on which image the user clicks.

It appears that I can find out what node has been clicked by using the EventSink service. However, that means I need to write code at the diagram level to interpret the events and hand back control to the relevant calling routine.

Is there a way to encapsulate that code within the derived class? For instance the OnMouseClick() event overrides for the group okay, but it does not tell me which node triggered the event. I know I can "find" the parent diagram from the node I am on, find the current mouse position and the find out which node that relates to... But that seems excessive.

I have tried deriving a new class from the BitmapNode class and overriding that OnMouseClick event but that does not appear to then fire at all. (Although that might be related to the "features" of polymorphism...)

I then want to apply the same logic to the OnMouseEnter & OnMouseLeave events...

Is there a solution I have missed?

Thanks,


8 Replies

DM Dinesh M Syncfusion Team February 3, 2010 05:56 PM UTC

Hi Aubyn,

Though I couldn't able to get very clearly what you have tried for, I assume the following from your requirement that you want to find the child node being clicked within a parent(group) node. Let me know whether my assumption is correct and if so please check the following sample.

http://help.syncfusion.com/support/Diagram.Windows/KB/GroupsChild/main.htm

Also if you are trying to achieve the same with a Custom Node(derived from Group) then try using "HandlesHitTesting" utility class members.

Regards,
Dinesh


AC Aubyn Crawford February 11, 2010 03:02 PM UTC

Hi,

Your second point was more relevant - i.e. it's in a class derived from Group. However, using (I think) HandleHitTests then relies on finding the current MousePoint from within an event that does not supply the current mousepoint position.

The for the lack of clarity on my questions is that I don't mind (sort of) what the solution is. I don't mind whether I intercept events or do hit tests.

The important thing is:

1) The dervied class does all the event handling
2) I would prefer not to rely on hit-tests or cycling through collections

I can put an actual code snipet if you want, but in pusdeo code:

class SpecialNode: Group
{
SpecialNode() {
* add img1 and img2
* connect img1.NodeClick += eventhandler(img1_NodeClick)
}

void img1_NodeClick
{
//Do some processing specific to clicking on img1
}

}

If the above concepts will never work, and I have to find the parent diagram to get he current mouse position, is there an easier way to do that than using base.Root.Container.Components?

Thanks,


DM Dinesh M Syncfusion Team February 12, 2010 11:42 AM UTC

Hi Aubyn,

In our latest version we have changed the "OnMouseClick" implementation for node which now has an "MouseEventArgs" in it.

class CustomGroup : Group
{
public CustomGroup()
: base()
{
}

protected override void OnMouseClick(EventArgs e)
{
base.OnMouseClick(e);
}
}

Therefore I hope now you can able to find the mouse position and use HandlesHitTesting to find the child node being clicked.

The latest version can be obtained from the following link.

http://www.syncfusion.com/support/forums/general/92880/essential-studio-2010-volume-1-final-release-v81030-available-for-download

Regards,
Dinesh


AC Aubyn Crawford February 12, 2010 12:42 PM UTC

I will download and use! Thanks


AC Aubyn Crawford February 12, 2010 12:44 PM UTC

Putting on my "theoritical hat" on (i.e. I have a solution now, but like to ask the question)...
Is there any reason why, in the future you would not support event trapping at the derived class level?

Thanks,

Aubyn



DM Dinesh M Syncfusion Team February 15, 2010 12:45 PM UTC

Hi Aubyn,

Thanks for your suggestion and this requirements needs re factoring of our existing architecture and hence we cannot go for such a major change, however will make every effort to implement features that would provided the way/workaround to achieve such a functionality.

Regards,
Dinesh


AC Aubyn Crawford February 19, 2010 11:50 AM UTC

Hi,

That all worked great.

However, the MouseEnter & MouseLeave functions did not have the same MouseEventArgs added, and that would be useful to implement tooltips.

Is there any chance they will be included in the Enter & Leave functions?

Thanks,

Aubyn


DM Dinesh M Syncfusion Team February 22, 2010 06:02 PM UTC

Hi Aubyn,

We will consider this as feature request and implement it if compatible with our existing architecture however you could post the same in an incident as a follow up could be made in it.

Regards,
Dinesh

Loader.
Live Chat Icon For mobile
Up arrow icon