How to draw a point (on mouseclick) on a QGraphicsScene?

UPDATE: There is a new class called QGraphicsSceneMouseEvent that makes this a little easier. I just finished an example using it here: https://stackoverflow.com/a/26903599/999943 It differs with the answer below in that it subclasses QGraphicsScene, not QGraphicsView, and it uses mouseEvent->scenePos() so there isn’t a need to manually map coordinates. You are on the right track, … Read more

How to use jQuery to show/hide divs based on radio button selection?

Update 2015/06 As jQuery has evolved since the question was posted, the recommended approach now is using $.on $(document).ready(function() { $(“input[name=group2]”).on( “change”, function() { var test = $(this).val(); $(“.desc”).hide(); $(“#”+test).show(); } ); }); or outside $.ready() $(document).on( “change”, “input[name=group2]”, function() { … } ); Original answer You should use .change() event handler: $(document).ready(function(){ $(“input[name=group2]”).change(function() { … Read more

What are the significant differences among $(sel).bind(“click”, $(sel).click(, $(sel).live(“click”, $(sel).on(“click”?

bind() was added in 1.0, live() in 1.3, delegate() in 1.4.2 and on() in 1.7. As of 1.7 on() is the preferred use and live() is deprecated and not recommended at all. If you are using 1.3 use bind() instead of live() and as of 1.4.2 use delegate() instead of live() and as of 1.7 … Read more

Marker mouse click event in R leaflet for shiny

You want to use input$MAPID_marker_click. See the example below. library(shiny) library(leaflet) latitude <- c(35.94077, 35.83770, 35.84545, 35.81584, 35.79387, 36.05600) longitude <- c(-78.58010, -78.78084, -78.72444, -78.62568, -78.64262, -78.67600) radius<-c(15, 12, 12, 12, 12, 15) ids<-c(“a”, “b”, “c”, “d”, “e”, “f”) shinyApp( ui = fluidPage( fluidRow( leafletMap( “map”, “100%”, 400, initialTileLayer = “//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png”, initialTileLayerAttribution = HTML(‘Maps by … Read more

Disallow Twitter Bootstrap modal window from closing

I believe you want to set the backdrop value to static. If you want to avoid the window to close when using the Esc key, you have to set another value. Example: <a data-controls-modal=”your_div_id” data-backdrop=”static” data-keyboard=”false” href=”#”> OR if you are using JavaScript: $(‘#myModal’).modal({ backdrop: ‘static’, keyboard: false });

How to simulate a click by using x,y coordinates in JavaScript?

You can dispatch a click event, though this is not the same as a real click. For instance, it can’t be used to trick a cross-domain iframe document into thinking it was clicked. All modern browsers support document.elementFromPoint and HTMLElement.prototype.click(), since at least IE 6, Firefox 5, any version of Chrome and probably any version … Read more

How to simulate a mouse click using JavaScript?

(Modified version to make it work without prototype.js) function simulate(element, eventName) { var options = extend(defaultOptions, arguments[2] || {}); var oEvent, eventType = null; for (var name in eventMatchers) { if (eventMatchers[name].test(eventName)) { eventType = name; break; } } if (!eventType) throw new SyntaxError(‘Only HTMLEvents and MouseEvents interfaces are supported’); if (document.createEvent) { oEvent = … Read more