I have two widgets listening for a MouseOutEvent. Problem is that sometimes this events does not get called on both of the widgeth even if you mouse out of them.
No error is thrown and this is extremely hard to debug.
My understanding is that this event is fired by a browser, so I don't understand why this is not happening. I am registering this event to the widget itself.
Any suggestions will be a great help.
Thanks
Sounds like you might have used addHandler to register to your MouseOverHandler. Widget has two methods for adding event handlers, addDomHandler and addHandler. The first is meant to be used for DomEvents, e.g. MouseOutEvents. It sinks the event on the widget, which means that your listener will get notified (this is only necessary for DomEvents). Those events might not get fired if you do not use addDomHandler to register your handler.
Related
Pretty much like the official tutorial here https://facebook.github.io/react-native/docs/tutorial.html:
I have the fetchData method called in ComponentDidMount, but according to this, ComponentDidMountwould only be called once after initial rendering of the component. So should I do call the same fetchData everytime before I navigate back to this ListView, and pass the updated data as props to the ListView, and then update the listView's state parameter accordingly in componentDidUpdate? Or is there any better way to do this?
You should register an event listener on componentDidMount and unregister it on componentWillUnmout, and emit events whenever and wherever you change the data your component displays.
Good rundown of this pattern here: https://colinramsay.co.uk/2015/07/04/react-native-eventemitters.html
Is it possible to see (debug) custom events being fired from DOM elements in the browser?
Let's say I want to see which specific element of the Bootstrap Collapse fires the show.bs.collapse event, can I somehow see it for instance in Chrome dev tools?
First off, Monitor Events will handle this for normal JS events. However, Bootstrap events are jQuery events, so vanilla JS event listeners don't listen for them.
To listen to jQuery events run the following code snippet in your console:
jQuery('body').bind("show.bs.collapse", function(e){console.log(e);});
Replace "shown.bs.collapse" with whatever event you want. When they are logged, just check the target element for the event to know what fired it.
Now, for the other way around, to see what is listening to events. Within the elements panel, if you go to the event listener tab and uncheck "ancestors", then you will see only the directly bound event listeners on an element. This way you know what is listening for the event so you can inspect what should be done when it is fired. This matters, since you may find 'body' isn't getting the event, since it could have bubbling cancelled. So if the above snippet isn't working, you need to check for bubble cancelling in the element listening for the event.
Firefox offers out of the box, listeners for jQuery events, https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_event_listeners
But you can extend it: http://flailingmonkey.com/view-jquery-and-jquery-live-events-in-firefox-devtools/
You can use Visual Event 2 bookmarklet. Great tool used to inspect which events are attached to a specific DOM elements.
in gwt Panel.clear() method clears all child widgets. Does that mean all even handlers associated with those child widgets will be removed or garbage collected as well?
Yes, it will (at least if the child widget cleaned their reference to application-transversal objects like the eventBus and don't hold circular references).
As per this documentation
The core GWT widget
system has a very specific event-handling system that makes it
impossible to trigger a leak.
It will also work in IE, as long as you
don't go straight to JSNI and hook up event handlers yourself (using
things like Event.sinkEvents() is just fine).
Calling Widget.removeEventListener() or
HandlerRegistration.removeHandler() is never necessary (or useful)
for any reason other than that you want to stop
receiving events (this is one reason we tucked removeHandler() into
HandlerRegistration -- most people never need to call it).
and this blog post.
However, removeHandler is required to avoid application-level, java-esque memory
leaks.
If you have a “global” event source, like an always-visible navigation
bar widget or an application-wide EventBus, and you have a transient
event listener, like a presenter listening for events, the presenter’s
event handler will keep it from being garbage collected until the
EventBus is also garbage collected.
So don't worry about widgets or #UIHandler. Just clear the tab and it'll work.
No it will not. You have to call removeHandler(). (eventually)
In this doumcnetation:
>
2 . removeHandler is required to avoid application-level memory leaks.
If you have a “global” event source, like an always-visible navigation
bar widget or an application-wide EventBus, and you have a transient
event listener, like a presenter listening for events, the presenter’s
event handler will keep it from being garbage collected until the
EventBus is also garbage collected.
what if I do a viewer.refresh() at the same time I close the tree viewer on the UI.
What will happen and how I can handle this situation?
This shouldn't happen in the same time, as UI events (such as close or refresh) are inherently single-threaded - they can happen only one after the other (unless you call refresh inside the dispose, or dispose during refresh, however both of them are hard to justify as normal steps)..
If your question was motivated by an SWT error of widget is disposed, then most likely you have disposed of something previously, but nonetheless called its refresh method - I would look it at that way.
Maybe you have more than one listener and trees around? I would advice to add a disposeListener to the tree and put a breakpoint into it. Then you see when it gets disposed.
I am doing a GWT application and speed tracer says that the painting process take a long time, so reading the pdf of the : Google 2010 - IO session ("Architecting for performance with GWT"), this sentence appear :
When should I use widgets?
When a component must receive events AND
There's no way to catch events in the parent widget
I agree with the first condition (I want to use widgets because my component, such as textBox or images must receive events, such as MouseOver, MouseClick...) but my question concern the second condition. Indeed I do not understand in which case there should be no way to catch event in the parent widget since it is ("always") possible to access to any element/component manipulating the DOM with Javascript. Here I am supposing that with Javascript I can access to the Widgets (identified with ui:field for example in ui:binder) element and the DOM elements (identified with id="").
So could you tell me why I am wrong or give me an example when "There's no way to catch events in the parent widget" ?
Thanks you,
It's more about "no easy way to put code that would catch events in the parent widget". It's all about componentization: you don't want to put event handling code outside your component, and you don't want to make your event handling code attach to elements outside your component. So components still are widgets, but inside them try to use HTML and event bubbling as much as possible.
In practice, that means using HTMLPanel (or RenderablePanel for better perfs, if you use 2.5.0 RC1 and you're a bit adventurous) inside composites, and otherwise using CellWidget (with UiRenderer to make it way easy to handle events bubbling from specific child elements)