I have a CellTable with ClickableCell. When I click on it, a popup opens and show the clicked cell table as exepected. The CellTable is added in a AbsolutePanel(Parent).
For some developpment, an another AbsolutePanel(Over) is located over the CellTable.
How can I propagate the AbsolutePanel(Over) click event on the celltable ?
I had an handler on the AbsolutePanelHandler(Over) and fired the clicked event :
absolutePanelOver.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
NativeEvent nativeEvent = Document.get().createClickEvent(0, -event.getScreenX(), event.getScreenY(),
event.getClientX(), event.getClientY(), event.isControlKeyDown(), event.isAltKeyDown(),
event.isShiftKeyDown(), event.isMetaKeyDown());
DomEvent.fireNativeEvent(nativeEvent, cellTable);
}
}, ClickEvent.getType());
Unfortunately the popup cell table is not shown. But I know that the cellTable handles the event.
Regards
Maybe I did not understand your question, but the solution seems to be much simpler.
absolutePanelOver.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
doSomething();
}
}, ClickEvent.getType());
In your CellTable you invoke the same doSomething() method when a cell is clicked. Now it does not matter whether a cell or an absolute panel is clicked - the same method will be executed.
Related
{final Button tab3button2 = view findViewById(R.id.button2); View.OnClickListener() { #Override pubilc void onClick (View v)
I have tried searching for answers but all to no avail.
Just copy the code for on click on source code, and you must have a section like bindview or webview to get at the id of widget. Then just enter I'd, make sure it's different then all others on same page.
Here is what you need, I edited your code:
final Button tab3button2 = view findViewById(R.id.button2);
tab3button2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View _view) {
here put the blocks that will be executed when the button gets clicked
}
});
it's recommended to add this code in the onCreate event, but if this Button is in a ListView custom view then add it in the onBindCustomView event.
In xamarin.forms I want to have a button that will only works if is pressed by 5 seconds
How can I detect that?
Unfortunately there is no OnTouchDown/OnTouchUp-like events available in Xamarin.Forms.
The Clicked event and the TapGestureRecognizer occur after the touch is complete (ie. press is released).
But you can create a custom control subclassing Button, with the following properties:
public event EventHandler PressStarted;
public event EventHandler PressEnded;
And the following public methods:
public void OnPressStarted()
{
if (PressStarted != null)
{
PressStarted(this, EventArgs.Empty);
}
}
public void OnPressEnded()
{
if (PressEnded != null)
{
PressEnded(this, EventArgs.Empty);
}
}
Then create a renderer per platform to be able to count the time that has pressed the button.
You can use your own button with using Mr.Gesture plugin (paid plugin).
It has OnTouchDown/OnTouchUp event.
Is there a way to process click event in cell's widget?
I implemented custom complex cell with text and image. Wrap it with FocusPanel and declare a click handler. But CellTable and CellList intercept all events.
There is a way of doing it directly, no wrapping:
table.addCellPreviewHandler(new Handler<MyObject>() {
#Override
public void onCellPreview(CellPreviewEvent<MyObject> event) {
if ("click".equals(event.getNativeEvent().getType())) {
// do something with a click, using event.getColumn(),
// event.getIndex() and event.getValue() as necessary
}
}
});
I need to get an event fired after clicking on a grid cell. It works but fires multiple events.
My Code:
private void gridClickHandler(final boolean cardDeterminer) {
gridClickHandler = new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
int cellIndex = view.getGrid().getCellForEvent(event)
.getCellIndex(); // get clicked cell of grid
if (cardDeterminer)
oasisCardRPC(cellIndex); //rpc based on clicked cell
else
desertCardRPC(cellIndex); //rpc based on clicked cell
}
};
view.getGrid().addClickHandler(gridClickHandler);
}
The method gridClickHandler is called in an onSuccess of a RPC and calls a new RPC using a boolean passed. (it works like this: click on some widget, when success then click on grid. Grid should only fire event, when this some widget was clicked directly before)
I don't know how to create a new ClickHandler only once for the grid and still make its clickHandler only fire events, when needed.
Thanks in advance!
Use a boolean : isClickHandlerAttached
Initially false, first time you add the clickhandler put it on true. Only attach if boolean is false.
I am trying to implement an Event on a RadioButton:
radio_Email.addSelectionListener(
new org.eclipse.swt.events.SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
// TODO Auto-generated Event stub widgetDefaultSelected()
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
System.out.println("This is printed twice "
+ "if i try to toggle between two radio buttons");
}
}
);
I know this is getting called twice : the first time for deselecting the first radio button and the second time for selecting the second radio button.
But i could not figure out how to solve it....can anybody help me with this
Note: The radio buttons are generated dynamically so there might be n radio buttons and hence this is inside a for-loop(just in-case..some additional info)...on page load..when i select the first one, event is called once...but when I click on a second one...then the event is getting fire twice.
Thanks in advance
i have solved it....
modify the widgetselected method as
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
boolean isSelected = ((Button)e.getSource()).getSelection();
if(isSelected){
system.out.println("Now this solved the problem")
}
}