A DESCRIPTION OF THE PROBLEM :
In method buildEventDispatchChain of class javafx.controls.MenuItem, the method buildEventDispatchChain(tail) is called on the parent popup and on the parent menu (if available).
In both cases, the returned chain objects are ignored:
/** {@inheritDoc} */
@Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) {
// FIXME review that these are configure properly
if (getParentPopup() != null) {
getParentPopup().buildEventDispatchChain(tail); // ERROR: returned chain is ignored!
}
if (getParentMenu() != null) {
getParentMenu().buildEventDispatchChain(tail); // ERROR: returned chain is ignored!
}
return tail.prepend(eventHandlerManager);
}
Instead, the returned chains should be used as new tails:
/** {@inheritDoc} */
@Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) {
// FIXME review that these are configure properly
if (getParentPopup() != null) {
tail = getParentPopup().buildEventDispatchChain(tail);
}
if (getParentMenu() != null) {
tail = getParentMenu().buildEventDispatchChain(tail);
}
return tail.prepend(eventHandlerManager);
}
The reason why the current implementation works in spite of this bug is, that the default implementation of EventDispatchChain, class com.sun.javafx.event.EventDispatchChainImpl, always changes itself and returns 'this' when a dispatcher is appended or preprended to it - which is allowed, but not required according to the API doc.
Some (future) implementation of EventDispatchChain might instead return a different chain, in which case the current implementation of MenuItem#buildEventDispatchChain would not work as expected any more.
FREQUENCY : always
In method buildEventDispatchChain of class javafx.controls.MenuItem, the method buildEventDispatchChain(tail) is called on the parent popup and on the parent menu (if available).
In both cases, the returned chain objects are ignored:
/** {@inheritDoc} */
@Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) {
// FIXME review that these are configure properly
if (getParentPopup() != null) {
getParentPopup().buildEventDispatchChain(tail); // ERROR: returned chain is ignored!
}
if (getParentMenu() != null) {
getParentMenu().buildEventDispatchChain(tail); // ERROR: returned chain is ignored!
}
return tail.prepend(eventHandlerManager);
}
Instead, the returned chains should be used as new tails:
/** {@inheritDoc} */
@Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) {
// FIXME review that these are configure properly
if (getParentPopup() != null) {
tail = getParentPopup().buildEventDispatchChain(tail);
}
if (getParentMenu() != null) {
tail = getParentMenu().buildEventDispatchChain(tail);
}
return tail.prepend(eventHandlerManager);
}
The reason why the current implementation works in spite of this bug is, that the default implementation of EventDispatchChain, class com.sun.javafx.event.EventDispatchChainImpl, always changes itself and returns 'this' when a dispatcher is appended or preprended to it - which is allowed, but not required according to the API doc.
Some (future) implementation of EventDispatchChain might instead return a different chain, in which case the current implementation of MenuItem#buildEventDispatchChain would not work as expected any more.
FREQUENCY : always