Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Handling events on the client side (Read 3286 times)
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Handling events on the client side
Nov 16th, 2006 at 11:45am
Print Post  
This new build of the control lets you handle events through client-side JavaScripts -
https://mindfusion.org/_beta/NetDiagram.zip

It adds to the FlowChart class several string properties of the form [EventName]Script, which should specify the name of a JavaScript function that must be called to handle an event. The event properties and the expected JavaScript function prototypes are listed below -

property name expected JavaScript function prototype
AppletStartedScript onAppletStarted()
ArrowCreatedScript onArrowCreated(arrow)
BoxCreatedScript onBoxCreated(box)
TableCreatedScript onTableCreated(table)
ArrowCreatingScript bool onArrowCreating(arrow, mouseX, mouseY)
BoxCreatingScript bool onBoxCreating(box, mouseX, mouseY)
TableCreatingScript bool onTableCreating(table, mouseX, mouseY)
ArrowModifiedScript onArrowModified(arrow)
BoxModifiedScript onBoxModified(box)
TableModifiedScript onTableModified(table)
ArrowModifyingScript bool onArrowModifying(arrow, handle, mouseX, mouseY)
BoxModifyingScript bool onBoxModifying(box, handle, mouseX, mouseY)
TableModifyingScript bool onTableModifying(table, handle, mouseX, mouseY)
ArrowSelectedScript onArrowSelected(arrow)
BoxSelectedScript onBoxSelected(box)
TableSelectedScript onTableSelected(table)
ArrowDeselectedScript onArrowDeselected(arrow)
BoxDeselectedScript onBoxDeselected(box)
TableDeselectedScript onTableDeselected(table)
ArrowClickedScript onArrowClicked(arrow, mouseX, mouseY, button)
BoxClickedScript onBoxClicked(box, mouseX, mouseY, button)
TableClickedScript onTableClicked(table, mouseX, mouseY, button)
ArrowDblClickedScript onArrowDblClicked(arrow, mouseX, mouseY, button)
BoxDblClickedScript onBoxDblClicked(box, mouseX, mouseY, button)
TableDblClickedScript onTableDblClicked(table, mouseX, mouseY, button)
CellClickedScript onCellClicked(cell, table, column, row, mouseX, mouseY, button)
CellDblClickedScript onCellDblClicked(cell, table, column, row, mouseX, mouseY, button)
ArrowDeletedScript onArrowDeleted(arrow)
BoxDeletedScript onBoxDeleted(box)
TableDeletedScript onTableDeleted(table)
TreeExpandedScript onTreeExpanded(root)
TreeCollapsedScript onTreeCollapsed(root)
DocClickedScript onDocClicked(mouseX, mouseY, button)
DocDblClickedScript onDocDblClicked(mouseX, mouseY, button)
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Handling events on the client side
Reply #1 - Nov 16th, 2006 at 12:11pm
Print Post  
The arrow, box and table parameters passed to the event handlers are Java objects, whose methods can be called from JavaScript in order to change the objects' appearance or state. For help on the available methods, see the documentation available for our Java diagramming control -
https://mindfusion.eu/JDiagramTrial.zip

Continuing our last example, set the BoxCreatedScript property to "onBoxCreated" and BoxModifiedScript to "onBoxModified", then add the following code to the .aspx page source:

Code
Select All
<script language="javascript">
function onBoxCreated(box)
{
  box.setText("123");
}
function onBoxModified(box)
{
  box.setBrush(<%=fc.AppletName%>.getScriptHelper().createSolidBrush(100, 150, 255));
}
</script>
 



Note how you can get the applet's name, through which you can access its API from JavaScript, using the <%=fc.AppletName%> statement.

Now run the page and draw or move around some boxes. You should see the "123" text appear in newly created boxes, and moved boxes will change their fill color.

We have tested client side event handling in IE, Opera and Firefox. Unfortunately, a known bug in Firefox 2 prevents calling JavaScript functions from applets, so client side event handling works only with 1.5.* or older versions of Firefox. That's a reported bug on Bugzilla.com and hopefully will be fixed in the next Firefox release.

Now with that functionality available, we will try to create for the next installment of this series a nice example that will use ASP.NET AJAX (aka "Atlas").

Stay tuned  Roll Eyes
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint