How can I get all connections for selected block in jsplumb and make all connections to red - jsplumb

How can I get all connections when I select particular block from group and make all connections to be red?
I am using jsplumb to make flow chart and my requirement is that when I will click on any block so all the to and from connections needs to be turn red.

Related

Issue while dragging elements inside a group

I have two groups and each group has a child element inside. Both child elements are connected using JsPlumb 5.12. When I click on the element and drag, the connections are broken.
For example. 'group1' has a child element 'elem1' and 'group2' has a child element 'elem2'. 'elem1' and 'elem2' are connected using JsPlumb connect method. when either of 'elem1' or 'elem2' is clicked and dragged, the connection lines are broken.
I saw the same issue in a demo which was part of JsPlumb doc. Has anyone faced this issue. How did u overcome this? I have attached the demo below.
As you can see when the child element of a group is dragged the connection is broken. It works fine when any other region of a group is dragged other than the child element.
Also is there a way to make a child element of a group not draggable?
If you think you have found a bug you'd be best off opening an issue on Github ( I refer to your statement "when the child element of a group is dragged the connection is broken" ).
Regarding switching off drag inside a group, there is a setDraggable(el, state) method available on the jsPlumb instance which you could call to disable drag for some element.

Examples of using body_entered and body_exited in Godot 3D (version 3.4.4)

I am trying to make a teleport part, so I need to detect when Body collides with area. I tried to use body_enter/body_entered and body_exit/body_exited, but I do not know how exactly they work and where do I need to insert them. Can I have example codes of using it?
My nodes path:
RigidBody
├ CollisionShape
├ MeshInstance
├ Area
├ ├ CollisionShape
Scene tree structure
First of all, if you want two things to collide you probably want them to be siblings. Not one Node child of the other. This is because Spatials are placed relative to their parent. Said another way: when an Spatial moves, its children move with it.
Enable monitoring
Second, you want to make sure that the Node that will detect the collision is able to do it. In the case of a RigidBody and an Area, the Area will detect the RigidBody, and for that it must have monitoring to be true This is the default. Thus, unless you have been messing with it, you need to do nothing.
Layers and masks
Third, you want the layers and masks to overlap. In particular, you want the collision_mask of the Area to have bits in common with the collision_layer of the RigidBody. By default, they come with the first bit set, so this is also satisfied by default unless you have been messing with it.
SIGNALS
Fourth, you need to connect the "body_entered" signal of the Area. You have two ways to do that:
Using the editor:
Have the Area selected in the Scene panel (on the left by default), and then go to the Node panel (on the right by default) and then to the Signals tab.
There you should find "body_entered(body:Node)". Double click it. Or select it and then click the "Connect…" button at the bottom, or press enter.
Godot will ask you to select the Node you will connect it to. You can connect it to any Node on the same scene that has a script attached beforehand. I suggest to connect it to the Area itself.
Godot will also allow you to specify the name of the method that will handle it (by default the name will be _on_Area_body_entered).
Under "advanced" you can also add extra parameters to be passed to the method, whether or not the signal can/will wait for the next frame ("deferred"), and if it will disconnect itself once triggered ("oneshot").
By pressing the Connect button, Godot will connect the signal accordingly, creating a method with the provided name in the script of the target node if it does not exist.
From code:
To connect a signal from code you use the connect method. See also disconnect and is_connected.
So you can, use the connect method to connect the "body_entered" signal, like this:
func _ready() -> void:
connect("body_entered", self, "_on_Area_body_entered")
func _on_Area_body_entered(body:Node) -> void:
pass
This code is intended to work in a script attached to the Area itself. It is also possible to call connect from a Node to another. Please note that we are passing the name of the method we want to connect as parameter to the connect method, and thus it can be whatever you want.
The connect method has optional parameters to specify extra parameters, or if you want the connection to be deferred or oneshot.
To reiterate: simply adding a method won't work, you need to connect the signal to it. And there is no special name for the method, it can have any name you choose.
With that done, the method should execute when the RigidBody overlaps the Area.

jsPlumb Posse Example

Does anyone know of a working example for jsPlumbs Posses feature?
Since jsPlumb 2.0.0 there is another way of configuring multiple element drag - the concept of a posse. This is a group of elements that should all move whenever one of them is dragged. This mechanism is intended to be used for more "permanent" multiple drag arrangements - you may have a set of nodes that should always move together and they do not need to be considered to be "selected".
https://jsplumbtoolkit.com/community/doc/dragging.html

jsPlumb makeSource draggable move bug

I found a problem when setting the MapSource connectors.
In jsFiddle code, click on "Reverse" to plot again. When you try to move a div, notice that the background of the DIV it is with an open connector.
Commenting the following code:
instancia.makeSource(elem.pageSourceId, {
paintStyle:{ fillStyle:"transparent" },
//hoverPaintStyle: endpointHoverStyle,
//connectorPaintStyle: connectorPaintStyle,
//connectorHoverPaintStyle: connectorHoverStyle
});
This bug does not happen anymore, but I need this code to maintain the original style. Anyone have any idea what it might be?
https://jsfiddle.net/braziel/dvhh7hvg/
Please read carefully Creating an Endpoint to understand what happens:
Endpoints are created in a number of different ways:
jsPlumb.makeSource(...) - Makes some DOM element(s) a Connection source, allowing you to drag connections from it/them without having to first register any Endpoints.
jsPlumb.makeTarget(...) - Makes some DOM element(s) a Connection target, allowing you to drag connections to it/them without having to first register any Endpoints.
jsPlumb.connect(...) - Establishes a Connection between two elements (or Endpoints, which are themselves registered to elements).
jsPlumb.addEndpoint(...) - Adds an Endpoint to a given element or elements.
You try to use all the methods in your example and as result you are creating a lot of endpoints wich you can't control. My suggestion is to choose only one way and use it.

Windows Forms Button Click Status Text

My windows form application has a button that does 3 things:
1 - Show a message in a label.text: connecting.
2 - Connects to the database.
3 - Change the text of the label to connected.
The problem is that the first message, connecting, is not even shown... goes directly to connected because the compiler do all the background processing and this blocks the first message to be shown. Is stays like frozen until connects to database.
Is there a way to solve this problem?
This is most likely because your form is not redrawn\updated before your database connection takes place, meaning that the label update won't be seen.
Before you begin to connect the database, use Application.DoEvents(); which will cause the form to be updated, and the correct label to be shown.

Resources