Get value from selected Node in Treeview - winapi

I am dealing with Treeview control and I need to get a clear picture on now can I get the selected node's name from the treeview. I tried using After_click methods etc etc.
Which class gives the function for the same (CTreeCtrl?). What should I do in the BEGIN MAP and END MAP?
In other words, what event should I map this function to? Is there a click event for the nodes?

Hope this is what you were looking for:
Create an event handler for the Tree Control for TVN_SELCHANGED notification message.
This will let you code the parts for the click event on nodes.
Use the GetSelectedItem() method of the Tree Control to get the label of the selected node.
There is no need to map anything in the BEGIN_MESSAGE_MAP/END_MESSAGE_MAP part for this.

Related

GWT - How to stop propagation from a child's event to its parent

I'm building a GWT application with a Tree.
Every tree items represent an object which has a boolean attribute that we can set through a checkbox displayed in the tree item itself.
I have a selection handler to do some stuff on my tree which gets called on click on every tree items.
What I want to do, is to prevent selection event to firing up when I'm clicking on the checkboxes ...
However, checkboxes don't have a SelectionHandler, so I tried to put a ClickEventHandler with event.stopPropagation(), but SelectionHandler is still getting called ...
EDIT: actually SelectionHandler is getting fired before ClickEventHandler anyway ...
Thanks in advance
You might consider following this method provided in the GWT documentation here. That should do the bit what you are interested in.
Try using the separate click handler for the checkbox and use the event.StopProgation() there after inorder to prevent the event bubbling.
For stop propagation from child's event to parent in GWT you need to use
event.stopPropagation();

extjs Save component view state before removing it from parent component

Let me explain the my scenario. I am using ExtJS5. I have got a view component (let us name is viewOne) contain two combo boxes, button search and some action button, on click of search button the grid is populated. This viewOne is in a parent view component (viewParent). I need to load a second view (viewTwo) on selecting some grid row and clicking some action button a new view is loaded (viewTwo) in the parentView. When I come back from viewTwo to viewOne I need old values of combo boxes to re perform the search.
Currently I am storing the values of combo boxes in a store and set then when the after view render and call search. We have discarded card layout for this implementation.
I wanted to know how this can be done via Ext.state , I cannot find any example on the same that is close solution to my problem. Any other way of doing this ?
State seems reasonable for that. First of all you must set StateProvider (by calling Ext.state.Manager.setProvider) to instance of class which extends Ext.state.Provider.
Then state should work for you. Only thing that you must remember is to set stateful property to true and set stateId of the component.
Usually you don't need to save state by yourself. All built-in stateful components have defined state events. When such state event occur (eg. expand on panel) then state is saved automatically. You can customize state events by calling addStateEvents in initComponent.
To provide custom component state you should override applyState and getState methods. When you combine it with addStateEvents you have all what you need.
Example: http://jsfiddle.net/48jw81da/16/

D3 Tree-Interactive how to detect clicks on nodes both parents and childeren

Trying to receive a callback from clicks on node. Currently the example expands a parent node if you click on it to show the children nodes. I would like to be able to click on the child node and receive a call independent from the parent node clicks. But I would need to know which child node was clicked as well. How best would this be done?
Consider using the pointer-events css attribute on the parent elements:
d3.selectAll(_parents_).style("pointer-events","none");
and give the child nodes an on click function:
d3.selectAll(_children_).on("click", _somefunction_);
Not exactly sure if this is what you were asking, otherwise I'd suggest creating a jsfiddle to describe your intentions a little better

When handling browser events in a GWT CellTable, how do I get the most specific within a cell?

The onBrowserEvent method of an abstract cell returns a parent element.
If I have multiple HTML items rendered within the cell, such as spans or divs, how do I get and distinguish which one triggered the event?
NativeEvent#getEventTarget() will give you the exact element that fired the event. You can then walk up until you find an element with some discriminant (e.g. a specific CSS class name), or walk down from the parent element and use Element#isOrHasChild().
Have a look at how CompositeCell dispatches the event to the appropriate cell,or how ButtonCell checks that you clicked the button inside the cell.

How do I obtain the GWT widget that wraps a given DOM element?

When a click event occurs, I want to determine which of my widgets was clicked. Note that, for performance reasons, I specifically don't want to add click handlers to each of my widgets.
It's easy enough to obtain the element that was clicked (it'll be the event target of the native event), but then how do I find the corresponding widget?
There is no standard functionality for it, afaik. But you can do it in a similar way as is done in GWT's com.google.gwt.user.client.ui.Tree class.
Basically it work there by first collecting the chain of Elements from the Element of your root Widget to the element of the Widget that clicked (see private method collectElementChain in Tree class). With this chain of Elements the Widget is found by traversing from the Root widget down to the Widget clicked (see private method findItemByChain in the Tree class).
This works for Tree because the Widget and Element index of the children of each Widget/Element match, and because it only allows a specific widget set as TreeItem's.
Actually you can get the widget associated with the main element of a widget using either gwtquery or the DOM.getEventListener(element) method which returns the widget associated with an element.
You can check out my response in another thread for some working code: GWT - How to retrive real clicked widget?

Resources