DynaTree has two highlighted nodes on right click after left click - dynatree

My problem is whenever I left click a dynatree node then right click another dynatree node to display my context menu the node which was left clicked remains highlighted in blue so I end up with two nodes in blue. If I then right click successive nodes the highlighting works correctly but the left clicked node remains highlighted.
The left click processing clears the previous node on mouseup. I initiate context menu processing via
document.oncontextmenu=contextMenu
which is also called on mouse up.
I have tried to capture the right button mouseup event and make the context menu node active thinking that would change the state of the left clickked node but not so.
$("#tree").mouseup(function(e){
if(e.button == 2){
e.target.setActive();// right mouse up
}
});
How should I get the last left clicked node to unhighlight when another node is right clicked ? It does not look right to have two nodes highlighted at once. I have noticed the dynatree context menu demo does not unhighlight the previously left clicked node when another node is right clicked so is this by design ?? Can you get around it ?
Thanks,
Al

OK this works
In my myfile.js after I create the dynatree I added:
var dtnode; //dynatree node Global <--ADDED
var elem; //DOM node Global <--ADDED
Function BuildTree()
//ADDED following code after the dynatree was loaded
$("#tree").mouseup(function(e){
if(e.button == 2){ //RIGHT MOUSE UP
if(!(elem == null)){
var elem2 = e.currentTarget.document.activeElement;
dtnode = tree.getDtNodeFromElement2(elem);
dtnode.deactivate();
elem = null;
}
}else{//LEFT MOUSE UP
if(!(elem == null)){
elem = null;
}
elem = e.currentTarget.document.activeElement;
}
});
//In jquery.dynatree.js
//$Version: 1.1.1$
//$Revision: 481, 2011-03-02 07:25:35$
//The following changes were made:
getSelectedNodes: function() {
return this.tree.getSelectedNodes();
},
// AFTER THE ABOVE FUNCTION THE FOLLOWING FUNCTION WAS ADDED
getDtNodeFromElement2: function() {
return this.tree.getDtNodeFromElement2();
},
//********************************************************
getSelectedNodes: function(stopOnParents) {
var nodeList = [];
this.tnRoot.visit(function(node){
if( node.bSelected ) {
nodeList.push(node);
if( stopOnParents === true ){
return "skip"; // stop processing this branch
}
}
});
return nodeList;
},
// AFTER THE ABOVE FUNCTION THE FOLLOWING FUNCTION WAS ADDED
getDtNodeFromElement2: function(elem) {
var sourceNode = getDtNodeFromElement(elem);
return sourceNode;
},
Summary:
By keeping track of the last element to be left clicked and exposing the dynatree getDtNodeFromElement method through getDtNodeFromElement2 it is possible to call the deactivate method on the last left clicked node whenever the first right click of a node occurs. This eliminates simultaneous highlighting of tree nodes.

I need to add a short method I added to jquery.dynatree.js to make it work.
//--- Class members ------------------------------------------------------------
DynaTree.prototype = {
// Constructor
// member functions
getDtNodeFromElement2: function(elem) {
var sourceNode = getDtNodeFromElement(elem);
return sourceNode;
},

I know this is old, but I just ran into the same problem. When manually trying to manage 'dynatree-active' classes on nodes to force highlighting, I was having issues with multiple nodes being selected. By using a left click along with the right click, dynatree managed all of the selecting and deselecting active nodes.
$("#tree").mouseup(function(e){
if(e.button == 2) e.target.click();
});
I struggled with this one for a bit, I hope it can save someone some pain.

One more change I found while clicking around the display
Instead of
}else{//LEFT MOUSE UP
if(!(elem == null)){
elem = null;
}
elem = e.currentTarget.document.activeElement;
}
use
}else{//LEFT MOUSE UP
if(!(elem == null)){
elem = null;
}
elem = e.currentTarget.document.activeElement;
if(elem.tagName != 'A'){
elem = e.target;
}
}
This corrects a issue where the old highlighting problem reappears of a non A element is clicked.
Al

Related

Show button after two clicks Flash CS6 As2

I want to make my "button 3" visible after click in "button 1" and "button 2". How can I do it?
I have not tried any code cause I have no idea how to do this :p
You can use global variables for each bt and a listener for the last btn, for example, when you click bt1 replace the original value of the variable, lets say:
bt1 = 0; now could be bt1 = 1;
you write these somewhere in your first frame o in the root, just remember to point the right timeline if you write it outside your current timeline.
Let's say you write in the first frame of the root:
bt1=0;
bt2=0;
mybt._visible = false; //here you turn it off
onEnterFrame = function(){
if (bt1 == 1 && bt2 == 1){
trace("Say it Worked");
mybt._visible = true; //and here you turn it on
delete this.onEnterFrame;
}
}
Then each button must have something like:
on (release) {
_root.bt1 = 1; // or 2, depends on what button it is
// Your Actions
}
And your invisible button must have an instance name, in this case: "mybt"

Clicking on marker cluster wants to open spider with exact same location markers by default

I was trying to implement MarkerCluster (MS) with
Overlapping Marker Cluster (OMS). Everything seems to work just fine.
However, I am looking to modify the way OMS is works so that if I click on a cluster that has 2 points under it
When I click on any Cluster with 2 points in it with exact same geo location, its opens a marker and when I am clicking on that marker it's opening spider with 2 markers.
What I want when I am clicking on the
Cluster, straight a way it will open up spider with 2 markers, already
spend lot of times but still nothing worked.
I already tried many solutions, like
1.
I can track the marker when I am adding to OMS(oms.addMarker), and can
click depending on zoom_changed event of google map, but its not firing
spiderfy rather its firing click event of what we added to markers.....
2.
I have see a event spiderfy, so I tried to trigger that event with a
marker object (oms.trigger('spiderfy', marker);) but nothing working...
Here I am adding code snippet too:
mc = new MarkerClusterer(map, markers.locations, mcOptions);
google.maps.event.addListener(mc, 'clusterclick', function(cluster) {
enter code hereclusterClicked = true;
// HERE WE WANTS TO FIRE SPIDER FUNCTIONALITY ...
});
I could solve this problem, first of all it is obvious that you have implemented and Overlapping Xluster Marker Marker Cluster in your google maps.
My solution is something very simple.
We capture the click event of markerCluster.
obtain the markers of markerCluster.
check whether all the markerCluster markers are in the same position.
if they are in the same position we make a click event trigger the latter obtained the markerCluster marker.
In short this is the code:
var markerClusterer = new MarkerClusterer(map, allMarkers, {styles: styles[0], clusterClass: 'poiCluster', maxZoom:18});
google.maps.event.addListener(markerClusterer, 'click', function(cluster) {
var markers = cluster.getMarkers();
if(estanTodosEnLaMismaPosicion(markers)){
//to wait for map update
setTimeout(function(){
google.maps.event.trigger(markers[markers.length-1], 'click');
},1000)
}
return true;
});
function estanTodosEnLaMismaPosicion(markers){
var cont=0;
var latitudMaster=markers[0].getPosition().lat();
var longitudMaster=markers[0].getPosition().lng();
for(var i=0;i<markers.length;i++){
if(markers[i].getPosition().lat() === latitudMaster & markers[i].getPosition().lng() === longitudMaster ){
cont++;
}else{
return false;
}
}
if(cont==markers.length){
return true;
}else if(cont<markers.length){
return false;
}
}

How to detect a click on a form reset button from QtWebKit?

Looking at the signals in the QtWebKit API, I failed to find anything that would seem to me to be what I am looking for.
QWebView
linkClicked() seems to be the closest, but a reset button is no link, and definitely does not point to an URL.
QWebPage
I considered the following signals (judging by their name), but according to their description none of them match my purpose either: contentsChanged(), contentsChanged(), contentsChanged(), selectionChanged().
QWebFrame
None of its signals matches my purpose.
QWebElement
Here I can see how to get an object representing the button(s), but it has no signals whatsoever.
I want to catch a click in a reset button in order to store the data in the form before it gets cleared, so it can be restored later.
For now, I did manage to retrieve the buttons as a QWebElementCollection of QWebElement objects, and I can modify them, but I do not know how to get them to send a signal upon click, or something similar.
// Get reset buttons.
QWebElementCollection inputResets = mainFrame()->documentElement().findAll("input[type=reset]");
inputResets += mainFrame()->documentElement().findAll("button[type=reset]");
// Change their text (just a test).
foreach(QWebElement element, inputResets)
{
element.setPlainText("Worked!");
}
Well, I got it working with this, although I do not think it is the best approach:
bool EventFilter::eventFilter(QObject* object, QEvent* event)
{
if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
QWebView *view = dynamic_cast<QWebView*>(object);
QPoint pos = view->mapFromGlobal(mouseEvent->globalPos());
QWebFrame *frame = view->page()->frameAt(mouseEvent->pos());
if (frame != NULL)
{
// Get the existing reset buttons.
QWebElementCollection inputResets = frame->documentElement().findAll("input[type=reset]");
inputResets += frame->documentElement().findAll("button[type=reset]");
// Check if any of them is at the clicked position.
foreach(QWebElement element, inputResets)
{
if (element.geometry().contains(pos))
{
qDebug() << "Clicked element tag:" << element.localName();
return QObject::eventFilter(object, event);
}
}
}
}
}
return QObject::eventFilter(object, event);
}
You can probably accomplish this with Qt WebKit Bridge.

Any link for Dojo sliding panel?

Can anyone help me with a link where I find Dojo sliding panel ? I have been searching for it but still didn't got it. I have sliding panel for jQuery, I got it from this link : http://web-kreation.com/all/implement-a-nice-clean-jquery-sliding-panel-in-wordpress-27/
You could make use of the dojo.fx.wipeIn functionality.
http://dojotoolkit.org/reference-guide/1.7/dojo/fx/wipeIn.html
So if you create two divs, one above the other, have the top one with display: none, and the other as the bit that you click to slide the panel down. Then use dojo.connect to link the clicking of the bottom panel to a wipe in of your top panel.
e.g.
// Have your main body content
var mainBody;
// Create top panel
var myPanel = document.createElement("div");
// Set visibility to none
dojo.style(myPanel, "display", "none");
// Create tab to expand your panel (or slide it down)
var expand = document.createElement("div");
expand.innerHTML = "click here to slide down";
mainBody.appendChild(myPanel);
mainBody.appendChild(expand);
var self = this;
dojo.connect(expand, "onclick", this, slidePanel);
Then you'd have your slidePanel function do something like:
// Get reference to your panel
var myPanel;
var wipeArgs = {
node: myPanel
};
// Then just wipe the panel in or out respectively
if (myPanel.style.display == "none") {
dojo.fx.wipeIn(wipeArgs).play();
} else {
dojo.fx.wipeOut(wipeArgs).play();
}

How to retrieve correspoding form element from dojo event object?

If there is a html form with a button, with normal html, we would be able to retrieve form element from the onclick event object as follows.
ev.target.form
As Dojo contains a its normalize event object, how can we retrieve event generated form element when a button is clicked ? (I require this as my dom tree contains duplications of same form element)
Thank you,
nimp
dojo.connect(dojo.byId("formsContainner"), "click", function(evt){
dojo.stopEvent(evt); // assuming you don't want to actually go to a new page
var n = evt.target;
while(n.tagName != "form"){
if(n.tagName == "body") break;
n = n.parentNode;
}
if(n.tagName == "form"){
myFormMethod(n);
return;
}
console.error('no form for button - clicked on something else')
});