GWT cells selection - gwt

I wish to make a drag and select application in GWT where I wish to have cell table or grid of say 20*100 columns*rows. I want to add a event such that I can drag something like a rectangle with my mouse and all the cells in that region get selected or I can fire an event for each cell and assign each of them a same ID. The main idea behind the thing is to perform a selection by dragging and then grouping all selected cells as one, something like Excel sheet selection. Can any one help me out in this?

I have once implemented GWT widget allowing to "select" some rectangular region of a table. Basically the idea was to subclass a Grid or FlexTable and do all the logic in various mouse event handlers (mouse down, mouse up, mouse out, mouse over).
The only minor hack I had to introduce was a method for getting the cell for any mouse event. There is a method HTMLTable#getCellForEvent that works for a click event, but when I looked into implementation of this method, I saw that it could actually work for any event, so I just implemented my own method for getting cell for any mouse event based on mentioned implementation.
Maybe it would be also possible to achieve this using HTMLTable#getEventTargetCell

Related

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.

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.

Distinguish buttons in swt spinner

I need to understand what button was pressed on the swt spinner. I tried adding listeners to swt events, but the verify, modify and selection events seem to have the same values regardless of the button pressed. The idea of getting the MouseDown coordinates and checking the vertical coordinate doesn't seems right.
Thanks,
Nik

Leafet.js: add button with link to zoombox function

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.

How do I make a Composite selectable in Eclipse?

I have an editor which is comprised of a table and a set of selection-specific form fields below it, so that when I make a selection in the table, the fields below it will change. When the editor is sized too small, the fields container gets a scrollbar:
The problem is that when I make a selection in the table, I can't scroll the fields container down (with the mouse wheel) because the focus is still within the table. Currently I have to select one of the fields to be able to scroll its container or manually drag the scrollbar itself, but it's much easier to just click or hover anywhere in the target container to focus it for mouse wheel scrolling.
How can I make the composite body (in my case, a Form) selectable? Or even better, is there a way to control scrolling depending on where the mouse cursor is?
If you want to control scrolling based on where the mouse cursor is located, you're going to have to write a combination org.eclipse.swt.events.MouseMoveListener and org.eclipse.swt.events.MouseWheelListener.
Component method setFocus() brings the component into keyboard focus.
I've not tried to do this. Be sure to handle the case where the user does not have a scroll wheel on their mouse.