## TSimpleGraph and OnClick event

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

### TSimpleGraph and OnClick event

Hello, i have to put a node when a user do click over the component SimpleGraph (canvas), but there isn't the event OnClick, how can i do that?
onlytk
Active Member

Posts: 9
Joined: October 30th, 2005, 1:46 am

Well, if ther isn't OnClick, OnMouseUp/Down/something else then I think all clicks takes component beyond SimpleGraph (for example form). If so you just need to check (in OnMouseDown/Up) if coordinates of mouse cursor are in area of your graph and then add a node.
Maybe it's not that simple, but it's worth trying. Just put ShowMessage('It works'); inside OnMouseClick/Down of form put SimpleGraph on it and try clicking it.
I'm not using SimpleGraph, so excuse me for saying something stupid if I did it.
EDIT: The other way is creating your own loop for taking care of Windows Messages that changes only standard reaction on clicking, and if click is outside of SimpleGraph's area just runs normal reaction (I think something like 'inherited' should do).
Active Member

Posts: 24
Joined: May 1st, 2005, 9:32 pm
Location: Poland

### Re: TSimpleGraph and OnClick event

Hello

onlytk wrote:Hello, i have to put a node when a user do click over the component SimpleGraph (canvas), but there isn't the event OnClick, how can i do that?

a user (G. Vaccaro) has added a modification to insert shape by click you may visit the following thread:

http://www.delphiarea.com/forum/viewtopic.php?t=448

hope that helps
lbc
Junior Member

Posts: 48
Joined: February 4th, 2004, 7:50 am
Location: Italy

### Re: TSimpleGraph and OnClick event

thanx lbc, i'll try that code.
onlytk
Active Member

Posts: 9
Joined: October 30th, 2005, 1:46 am

onlytk,

In the new release, I've added missing OnClick and OnObjectClick events to the SimpleGraph.

In a few hours I'll upload the files.

Cheers
Kambiz

Kambiz

Posts: 2426
Joined: March 7th, 2003, 7:10 pm

Ok Kambiz, i'll wait the new version, hehehe.

another question, is how can I determine if an object is unselected, in one event, example:

I'm doing the next: the user select a node and in a panel I have located a EditBox, and when the user select a node with the event OnObjectSelect I i get the text of the node and i put it in the editbox, but when the user deselect it my editbox persist with the text of the node, what is the event that i have to manage for it?. I'dont speak english very well, sorry if someone don't understand me

Cheers
onlytk
Active Member

Posts: 9
Joined: October 30th, 2005, 1:46 am

Hi,

OnObjectSelect occurs when selection state of an object changes.

You have to check the Selected property of GraphObject parameter to see whether the object is selected or deselected.

By the way, version 1.65 of the control is available to download.

Cheers
Kambiz

Kambiz

Posts: 2426
Joined: March 7th, 2003, 7:10 pm

thanks kambiz, thanx a lot
onlytk
Active Member

Posts: 9
Joined: October 30th, 2005, 1:46 am

Kambiz wrote:In the new release, I've added missing OnClick and OnObjectClick events to the SimpleGraph.

thank you Kambiz, great!

for anyone interested here is a simple snippet to insert a rectangular node at 10,10 by clicking (SG is of course a SimpleGraph)

Code: Select all
procedure TForm1.SGClick(Sender: TObject);var    R: TRect;begin  SG.DefaultNodeClass := TRectangularNode;  R :=  MakeRect(Point(10,10),Point(100,100));  SG.InsertNode(@R);end;
lbc
Junior Member

Posts: 48
Joined: February 4th, 2004, 7:50 am
Location: Italy