KeyUp event is not fired with ScrollViewer - event-handling

I am using Syncfusion's TreeViewAdv control. I attach a KeypUp event handler to it and it worked as expected. The event is fired whenever I released a key. However, once I wrap it in a ScrollViewer, the event is not fired. I have to move the event handler up to the ScrollViewer itself to catch the event. I aslo checked the PreviewKeyUp event, at the ScrollViewer it is fired and the Handled is false. But the PreviewKeyUp for TreeViewAdv is not fired at all.
I try to replace the ScrollViewer with a StackPanel and everything is fine. So it seems that the ScrollViewer stops event propagation to its content. How can I get the event handled within the ScrollViewer?

I could see that this is happening only when you select item through mouse and then trying to catch KeyUp and KeyDown events. These events are firing properly when you navigate items through keyboard only such as using Tab Key.
This is known issue in TreeViewAdv control and Syncfusion fixed this. They promised like fix will be included in their forth coming release Vol1 2010 which is scheduled on end of Jan 2009.
As a workaround, you can use this code snippet to receive the event notification.
<Syncfusion:TreeViewAdv.Resources>
<Style TargetType="{x:Type syncfusion:TreeViewItemAdv}">
<EventSetter Event="MouseLeftButtonUp"
Handler="TreeViewItemAdv1_MouseLeftButtonUp"/>
</Style>
</Syncfusion:TreeViewAdv.Resources>
Event handler in C#
private void TreeViewItemAdv1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TreeViewItemAdv item= (sender as TreeViewItemAdv);
If(item != null)
{
item.Focus();
}
}
Thanks,
Madhan

Related

dojox/gesture/swipe prevents the html select to open dropdown

can anyone please explain to me why the html SELECT control (or any other control like BUTTON) placed inside the div (that is registered with dojox/gesture/swipe events) cannot be opened? I'd welcome any workarounds pls
require({
}, [ 'dojo/dom', 'dojox/gesture/swipe', 'dojo/on', 'dojo/_base/event' ], function(dom, swipe, on, event) {
var div = dom.byId('testSwipe');
var isSwipe = false;
on(div, swipe.end, function(e) {
console.log("### SWIPE");
});
});
http://jsfiddle.net/zLyck884/
based on the documentation here, particularly the image : http://dojotoolkit.org/reference-guide/1.10/dojox/gesture.html
the image depicts how the dojo standardizes the events (also for desktops) and how the swipe is just another layer of the touch events. so I reckoned if the mouse events are replaced by touchstart or something, then it most likely blocks the default mouse action...
once I've stopped propagating the event (on the SELECT) further, then it worked ok.
query("select", this.domNode).on(touch.press, function(e){e.stopPropagation()});
where this.domNode is the element on which the swipe is enabled
on(this.domNode, swipe, lang.hitch(this, "_onSwipe"));
Unfortunately the swipe (touch) event overriding the default behaviour is not very handy, I just left dojox/gesture/swipe or touch for now. Seems like I'll rather implement my own touch event handling.

Fire JavaFX onAction event

It seems me to be so tired and silly now :) I want to fire button pressing event when certain condition is met. Here's my code:
#FXML protected void play(ActionEvent event) throws Exception {
if(menu.getText().equals("The certain text")) {
play.fireEvent(event); //Trying to cancel event
}
}
And when I press the button with fx:id "play", the app hangs. What am I doing wrong? Big thanks!
It is entering to the infinite loop. You are firing the event again in the event handler. However check the output log, there should be some exception thrown like "StackOverflowError", since the resources are not infinite :). So do not fire the event in the handler which can handle it again.
If you want to cancel the event, use event.consume() it will cause the action to stop.

How to use touch event to instead of click event on mobile website

It seems that click event have delay on website on iphone, but the touchstart or touchend could response correctly, but how to use the only touchstart, touchend and touchmove to simulate click event? or even simulate the long press event on a website on iphone?
I think I can't bind the click handler directly to the touchstart or touchend event, one situation is that when the user press on the screen , fire the touchstart event , but if he don't want a click event, how can he cancel it, either I can't bind the handler to the touchend event.
So how can I simulate the click event with touchstart and touchend event?Is there conflict or something should I mentioned?Is there some post or article talk about how can I achieve this?
I just made a chrome extension for this purpose. It translate mousedown, mousemove, mouseup events to touchstart, touchmove, touchend. It actually simulate iphone5.
https://chrome.google.com/webstore/detail/touchphone-simulator/jijkpkhmnpbecppjhicgegndbbgfnngf
I use phantom-limbs.js. If you want more functions like gesture(which i excluded in my extension), visit brian's github.
https://github.com/brian-c/phantom-limb

GWT handling onBlur is also stopping the propagation of the event [duplicate]

This question already exists:
Closed 10 years ago.
Possible Duplicate:
in Chrome not getting an onClick() on a FocusPanel when focus was on a TextArea that has registered onChange and onBlur handlers
In my GWT app I register a BlurHandler on a TextArea so that I can save the changes and go from edit mode back to view mode if the focus moves elsewhere. This works, but also seems to defeat the effect of the event that moved the focus, at least on Chrome in devmode. For example, if the user clicks on an Anchor, the TextBox gets the onBlur() and then the Anchor does not get the onClick(); whereas before I registered the onBlur, the Anchor would get the onClick(). This seems to be quite reliable (again, in Chrome in devmode). I am being careful to not call event.stopPropagation() or event.preventDefault(). Any ideas how I can get the onBlur and also the onClick() ?
I had a similar issue. I was not able to track the source problem though. I did enable dev toolbar / firebug and set event breakpoints to test; it does look like the click event was not triggered after the blur action. After playing around for many hours (and I'm not quite sure what inspired me to try this), I dropped the onblur action in a timer with executed delay at about 300ms. That seemed to work for me. I think it might have something to do with the fact that my action slightly modified the page and visibility of items, witch re-rendered the page and I can only guess that the single-threaded browser model killed the click event which was not longer on the right area.
textBox.addBlurHandler(new BlurHandler()
{
#Override
public void onBlur(BlurEvent event)
{
Timer delayTimer = new Timer()
{
#Override
public void run()
{
//do stuff
}
};
delayTimer.schedule(300);
}
});
anchor.addClickHandler(....)

GWT native event does not provide intended behavior

I have a text widget where I want to make enter event to behave like a tab event. so I capture the Key press event and raise a tab native event.
However the tab behavior is not reflected in the application. The code for event handler is
public void onKeyPress(KeyPressEvent event) {
int keyCode = event.getNativeEvent().getKeyCode();
if (keyCode == KeyCodes.KEY_ENTER) {
NativeEvent nativeEvent =
Document.get().
createKeyPressEvent(false,false,false,false,KeyCodes.KEY_TAB );
DomEvent.fireNativeEvent(nativeEvent, this, this.getElement());
}
When I use the deprecated createKeyPressEvent with more argument, it fires the tab event but the behavior is not as per the tab key press, which is to move to next widget. The new code changes from the above code in createKeyPress event line
as follows
NativeEvent nativeEvent =
Document.get().
createKeyPressEvent(false,false,false,false,
KeyCodes.KEY_TAB ,KeyCodes.KEY_TAB);
Note that manually firing an event
does not generate the default action
associated with that event. For
example, manually firing a focus event
does not cause the element to receive
focus (you must use its focus method
for that), manually firing a submit
event does not submit a form (use the
submit method), manually firing a key
event does not cause that letter to
appear in a focused text input, and
manually firing a click event on a
link does not cause the link to be
activated, etc. In the case of UI
events, this is important for security
reasons, as it prevents scripts from
simulating user actions that interact
with the browser itself.
From http://www.howtocreate.co.uk/tutorials/javascript/domevents.