| View previous topic :: View next topic |
| Author |
Message |
onlytk Member
Joined: 30 Oct 2005 Posts: 9
|
Posted: 09/11/05 21:13 Post subject: 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?
|
|
| Back to top |
|
 |
Radagast Member
Joined: 01 May 2005 Posts: 24 Location: Poland
|
Posted: 09/11/05 22:04 Post subject: |
|
|
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).
|
|
| Back to top |
|
 |
lbc Member
Joined: 04 Feb 2004 Posts: 48 Location: Italy
|
Posted: 10/11/05 09:39 Post subject: 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
|
|
| Back to top |
|
 |
onlytk Member
Joined: 30 Oct 2005 Posts: 9
|
Posted: 10/11/05 13:35 Post subject: Re: TSimpleGraph and OnClick event |
|
|
thanx lbc, i'll try that code.
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 10/11/05 13:47 Post subject: |
|
|
onlytk,
Wait please!
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 |
|
| Back to top |
|
 |
onlytk Member
Joined: 30 Oct 2005 Posts: 9
|
Posted: 10/11/05 16:54 Post subject: |
|
|
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
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 10/11/05 22:42 Post subject: |
|
|
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 |
|
| Back to top |
|
 |
onlytk Member
Joined: 30 Oct 2005 Posts: 9
|
Posted: 11/11/05 00:15 Post subject: |
|
|
thanks kambiz, thanx a lot
|
|
| Back to top |
|
 |
lbc Member
Joined: 04 Feb 2004 Posts: 48 Location: Italy
|
Posted: 11/11/05 11:05 Post subject: |
|
|
| 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: |
procedure TForm1.SGClick(Sender: TObject);
var
R: TRect;
begin
SG.DefaultNodeClass := TRectangularNode;
R := MakeRect(Point(10,10),Point(100,100));
SG.InsertNode(@R);
end;
|
|
|
| Back to top |
|
 |
|