Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram Node DeSelect & Select (Read 5782 times)
henry k
Junior Member
**
Offline


I Love MindFusion!

Posts: 51
Location: Finland
Joined: Apr 4th, 2012
Diagram Node DeSelect & Select
May 7th, 2012 at 8:00am
Print Post  
Hi,

I noticed that if NodeDesectedScript property is set and its related function called; when another node is selected when one is selected. The prev.ment. function is called but the new node selection is not raised. As result you'll have only deselection effect...

In simple:
Node-A : Clicked
Node-A : Selected
Node-B : Clicked
Node-A : DeSelected
the end. Sad

When Deselected Function is removed, swapping/toggling between nodes works, but the deselection is not raised in certain situations.. Which in my case will leave selected nodes information displayed even when the node doesn't exist. Also in case when link is deleted. There were also other scenarios which I can't get the handle (currently can't remember it, but there were several of those) so I need the Deselected function... :S

Br. Henry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Node DeSelect & Select
Reply #1 - May 7th, 2012 at 2:14pm
Print Post  
Hi,

This shows the correct events in my test:

Code
Select All
function onNodeSelected(sender, args)
{
	args.getNode().setText(args.getNode().getText() + "\n\rselected");
}

function onNodeDeselected(sender, args)
{
	args.getNode().setText(args.getNode().getText() + "\n\rdeselected");
} 



Please check if there isn't some exception shown in the Java console. If there is a "JSException" shown, probably there was an error thrown by your script.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
henry k
Junior Member
**
Offline


I Love MindFusion!

Posts: 51
Location: Finland
Joined: Apr 4th, 2012
Re: Diagram Node DeSelect & Select
Reply #2 - May 11th, 2012 at 12:24pm
Print Post  
I don't quite understand your answer.
If I understood it as you explained it then in that case you have not understood my case of problem.
If I try your sample and write rows (instead of renaming node) like in event-logging... then I get 4 rows when I'm suppose to get 5... and no JExceptions are formed.

[Start Log]:

Node_1 : Clicked
Node_1 : Selected (Node_1 is now selected)
Node_2 : Clicked
Node_1 : Deselected (Node_1 is now deselected)

Node_2 : Clicked { I clicked once again... }
Node_2 : Selected (Node_2 is now selected)

[End Log]

This is my log result...

Br. Henry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Node DeSelect & Select
Reply #3 - May 14th, 2012 at 6:48am
Print Post  
I don't understand your logs either... The new log shows "Node_2 : Selected (Node_2 is now selected)" as last logged line, which is what you expected in your original post where that line wasn't shown? Note that in multiple selection you might be getting Activated/Deactivated events if a node remains in the selection but only gets activated / deactivated. There's the diagram.ActiveItem property which refers to only one of the selected items, usually the last added to selection and its handles are painted in white. E.g. you can use it to implement alignment of selected nodes to the active one.
  
Back to top
 
IP Logged
 
henry k
Junior Member
**
Offline


I Love MindFusion!

Posts: 51
Location: Finland
Joined: Apr 4th, 2012
Re: Diagram Node DeSelect & Select
Reply #4 - May 15th, 2012 at 12:35pm
Print Post  
Stoyo wrote on May 14th, 2012 at 6:48am:
I don't understand your logs either... The new log shows "Node_2 : Selected (Node_2 is now selected)" as last logged line, which is what you expected in your original post where that line wasn't shown? Note that in multiple selection you might be getting Activated/Deactivated events if a node remains in the selection but only gets activated / deactivated. There's the diagram.ActiveItem property which refers to only one of the selected items, usually the last added to selection and its handles are painted in white. E.g. you can use it to implement alignment of selected nodes to the active one.



Please check the count of "clicks"...... as also the description between brackets.

Also I've already noticed the case of multiple selections, this is why I set a watcher for keyboards CTRL button...

Br. Henry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Node DeSelect & Select
Reply #5 - May 17th, 2012 at 6:48am
Print Post  
This is what I'm seeing by clicking 1 and then 2 with the code below, starting from empty selection. I think this is the correct sequence of events and nothing is missing. Clicking 2 again does not change the selection and adds only "2 clicked" to the log.



Code
Select All
<ndiag:DiagramView runat="server"
	ID="diagramView"
	Width="750px" Height="480px"
	ClientSideMode="JavaApplet"
	AppletStarted="onAppletStarted"
	NodeSelectedScript="onNodeSelected"
	NodeDeselectedScript="onNodeDeselected"
	NodeClickedScript="onNodeClicked"
	NodeCreatedScript="onNodeCreated"
    >
	<Diagram SelectAfterCreate="False" TableBrush="s:#FFFFFFFF" CellFrameStyle="None"></Diagram>
</ndiag:DiagramView>

...

<script type="text/javascript">
	var logTable;

	function onAppletStarted()
	{
		var diagram = <%= diagramView.AppletElement %>.getDiagram();
		logTable = diagram.getFactory().createTableNode(0, 0, 50, 200);
		logTable.setCaption("Log");
		logTable.redimTable(1, 0);
	}

	function log(message)
	{
		logTable.addRow();
		logTable.getCell(0, logTable.getRowCount() - 1).setText(message);
	}

	function onNodeSelected(sender, args)
	{
		log(args.getNode().getText() + " selected");
	}

	function onNodeDeselected(sender, args)
	{
		log(args.getNode().getText() + " deselected");
	}

	function onNodeClicked(sender, args)
	{
		log(args.getNode().getText() + " clicked");
	}

	function onNodeCreated(sender, args)
	{
		args.getNode().setText(args.getNode().getZIndex());
	}

</script>
 



In case you are calling a server method asynchronously to log events, perhaps they are not received in the same order on the server; I might be wrong but I think the order of completion of async. Ajax calls is not guaranteed. If you can't get the events to work, please attach a sample project that shows the problem.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint