Disable popups when a component is disabled


I'm not sure if this is a feature or a bug.  I have some components that derive from Label.  Using MouseListener::mouseDown() and PopupMenu, these labels also show some complicated lists of values the user can select.

There are times when I need to disable large parts of the screen.  So on one of the top parent canvas, I call setEnabled(false).  This has the desired effect, where all the children components take on a halftone disabled look, indicating to the user that the components in that part of the screen are unavailable.

Except for two small related items:

1) Where I have some KeyListener::keyPressed() to intercept some keys in the labels, they're still being called on components that are otherwise disabled.

2) Where I have the popup menu handler mouseDown(), they're also still being called on these same disabled components.

Is this a bug, or expected behaviour?  If a parent component is disabled, should all interaction with child components also be disabled, or is it up to me to call isEnabled() to weed out interaction when the parent is disabled?




It would definitely be wrong to automatically discard events for disabled components, since you would then be unable to provide 'negative' feedback about interactions with them (e.g. play a fail sound, show an alert, etc). Plus, the concept of enablement just doesn't have the same implications for all control types. If you need different behaviour between enabled/disabled states of a component, then you just need to check its enablement before you do anything.