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.
Unfortunately, activation email could not send to your email. Please try again.

Group Base Class an OnMouseClick() Event

Thread ID:

Created:

Updated:

Platform:

Replies:

92723 Feb 1,2010 03:51 PM Feb 22,2010 01:02 PM Windows Forms 8
loading
Tags: Diagram
Aubyn Crawford
Asked On February 1, 2010 03:51 PM

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,


Dinesh M [Syncfusion]
Replied On February 3, 2010 12:56 PM

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

Aubyn Crawford
Replied On February 11, 2010 10:02 AM

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,

Dinesh M [Syncfusion]
Replied On February 12, 2010 06:42 AM

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

Aubyn Crawford
Replied On February 12, 2010 07:42 AM

I will download and use! Thanks

Aubyn Crawford
Replied On February 12, 2010 07:44 AM

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


Dinesh M [Syncfusion]
Replied On February 15, 2010 07:45 AM

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

Aubyn Crawford
Replied On February 19, 2010 06:50 AM

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

Dinesh M [Syncfusion]
Replied On February 22, 2010 01:02 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;