Leafet.js: add button with link to zoombox function - leaflet

I need to add a control button with a "rectangle" zoom or what's called the boxZoom function in leaflet. I know that the function can be used when pressing shift and drawing a rectangle but I need a button that gets clicked and then the user can draw a rectangle which is used a bounds for the boxZoom function. I thought this wouldn't be difficult but I just can't figure it out.
Bonus points if you could tell me how to link other functions, e.g. of leaflet.draw, to my own buttons. I need to create my own button toolbar, so I need to be able to attach different functions to the buttons and would like to use already existing functions.

There isn't a one size fits all solution for this (thus the reason for L.Control.BoxZoom being its own plugin). You'll need to add buttons with click handlers, then read the API of Leaflet or the plugin you're integrating with (e.g. drawing) to find how to toggle the behavior.
The Leaflet.EasyButton plugin does a good job of encapsulating the creation of single button controls and click handlers in an easy way, and may be a good starting point if you're struggling with getting started.

Related

How to create using Flutter the _showMenu function, which dynamically builds the popup menu and allows to handle the selected option

The problem is this: I wrote using flutter, graphics editor, which allows to draw various shapes using gestures. I want to add an option: delete shape. To do this, need to tap on the shape and then a popup menu should appear with the option "delete". It is necessary to select "delete" and remove the object from scene. I need a simple function of type _showPopupMenu (). In it, need to build a menu and process the selection of the "delete" option. And it's all. Flutter has the function showMenu, but I do not understand how to use it in this case. I've found the link: https://github.com/flutter/flutter/issues/12931 and tried to use the code, but I didn't succeed.

Is there a way to add ui elements from code in netlogo?

In netlogo, the way to add say, a button is to click on the add button and select button demonstrated here. is there a way to do this from code, say when the setup button is clicked? I want to generate some monitors demonstrating some information after the setup button is clicked.
The eXtraWidgets extension allows you to create additional interface tabs in the NetLogo GUI and programatically put custom widgets on them.
Unfortunately, it doesn't work (yet) with NetLogo 6.0.
There also used to be the Goo extension, but it has been unmaintained for a while.

NSButton in Swift, handle click and release events

i'm trying to manage different state of a simple push button on an OS X application : When the user click on it, and when the user release the click.
Currently i set my button type by NSMomentaryLightButton
NSMomentaryLightButton When the button is clicked (on state), it
appears illuminated. If the button has borders, it may also appear
recessed. When the button is released, it returns to its normal (off)
state.
This type of button is best for simply triggering actions because it
doesn’t show its state; it always displays its normal image or title.
This option is called Momentary Light in Interface Builder’s Button
inspector
I thought it was the good way, but when i print my button status, it's like a toggle button than the push button that i set. As you can see on exemple gif
To sum up, How can i have a real push button behaviour ? Call function when the user click on it, and when the user release the click.
Thank,
You don't want to use buttons for piano keys. First, they are non-rectangular, and they don't act as buttons do: neither single-action push-button, nor toggle switches. You are interacting in a custom way, with a custom view, meaning the NSButton control hierarchy isn't called for. Instead you're subclassing NSView and capturing low-level mouse events as detailed here:
https://developer.apple.com/library/prerelease/content/documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/10000060i-CH6-SW1
You found this yourself as you detailed in your own comments, but I wanted to make sure you had a higher level point of view. It's even possible, and probably best, to consolidate all of the piano keys into a single view, and let the keys themselves be rendered using NSBezierPath and perform mouse hit detection using containsPoint:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBezierPath_Class/#//apple_ref/occ/instm/NSBezierPath/containsPoint:
This is a lot more work but the only way to make a truly professional looking piano simulation. Then you can render the keys with whatever outline, fill, and labeling you need without the limitations of built-in button shapes and layout. You could even have the bottom edges of the keys slightly rounded, for example, or apply a shiny texture.

Build some sort of workflow in JavaFX

I'm trying to build some sort of visual workflow in JavaFX. I want my application to have one main screen with the next and previous buttons, something like an installer. When a user clicks next, all the elements of the next screen appear in the same element. All previous choices of the user have to be saved. So when a user clicks on the previous button that all of his choices are still there.
How would I go on to do this?
I found these links on Google, but they don't seem to help me. Something like this is a bit the direction that I want to go, but the code in this tutorial isnt't really that good for scene's with a lot of elements.
The DataFX Framework provides a Flow API that can be used to define workflows. By doing so you can simply navigate between MVC Groups by only using annotations or configurations. You can find some examples of the API here:
http://www.guigarage.com/2014/06/datafx-tutorial-5/
http://www.guigarage.com/2015/02/quick-overview-datafx-mvc-flow-api/
http://www.guigarage.com/2015/01/datafx-tutorial-6/
I haven't worked with JavaFX in a while, but I'll start by saying I really hope you are using the JavaFX scene builder.
The way I would do it off the top of my head without going back and relearning JavaFX is to create a main window in the scene builder, and have a sort of central content display area, which holds another custom JavaFX container that contains the content you want to display, of which you can then create several of and swap out which one is being displayed programmatically.
Basically, create several smaller components representing each step or screen and display them programmatically in an owning container.

How can i make a moving button in GWT, so that users can move it to anywhere they want?

I just want to make a moving button , Is there a way to do that in GWT? Thanks in advance.
BS
Out of the box, you can use a DialogBox to display your button. DialogBox can be moved around, but you will need to display something in a Caption that is used for dragging.
Another option is to use PopupPanel. It can be completely invisible (no Caption), but you will have to implement dragging functionality on your own. The advantage is that a PopupPanel floats on top of all the other layers in your UI.
Finally, you can simply add dragging functionality to a regular button. Just remember to check for the boundaries so that a user cannot drag your button outside of the visible browser area - or obscure some important elements of the UI.